Amoy Testnet

Contract

0xE205F573AC35453C2fE0E2E28E8aF201c45464F4

Overview

POL Balance

Polygon PoS Chain Amoy LogoPolygon PoS Chain Amoy LogoPolygon PoS Chain Amoy Logo0 POL

Multichain Info

N/A
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ZTLNPrimeSubVaultUpgradeable

Compiler Version
v0.8.27+commit.40a35a09

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 27 : ZTLNPrimeSubVault.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

import '@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '../interfaces/ISubVault.sol';
import '../interfaces/IFundVaultV2.sol';
import '../interfaces/IPriceOracle.sol';

/**
 * @title ZTLNPrimeSubVault
 * @notice An upgradeable vault for managing ZTLN Prime token and additional supported assets
 * @dev Implements UUPS upgradeability pattern with comprehensive security measures
 *
 * INHERITANCE STRUCTURE:
 * - Initializable: Base contract for upgradeable pattern
 * - UUPSUpgradeable: Implements upgradeability pattern
 * - AccessControlUpgradeable: Role-based access control
 * - PausableUpgradeable: Circuit breaker pattern
 * - ReentrancyGuardUpgradeable: Protection against reentrancy
 * - ISubVault: Core vault interface
 *
 * SECURITY CONSIDERATIONS:
 * 1. Upgradeability
 *    - UUPS pattern with access control
 *    - Storage gaps for future versions
 *    - Initializer protection
 *
 * 2. Access Control
 *    - Role-based permissions (DEFAULT_ADMIN_ROLE, ADMIN_ROLE)
 *    - Router authorization
 *    - Emergency admin controls
 *
 * 3. Asset Safety
 *    - Non-reentrant operations
 *    - SafeERC20 usage
 *    - Balance validations
 *    - Explicit approval management
 *
 * 4. Emergency Features
 *    - Pause functionality
 *    - Emergency mode with timelock
 *    - Protected withdrawal system
 *
 * STORAGE LAYOUT:
 * Careful consideration for storage layout is crucial for upgradeability.
 * Never modify existing storage variable order or size.
 * Always append new storage variables at the end.
 *
 * @custom:security-contact [email protected]
 */
contract ZTLNPrimeSubVaultUpgradeable is
    Initializable,
    UUPSUpgradeable,
    AccessControlUpgradeable,
    PausableUpgradeable,
    ReentrancyGuardUpgradeable,
    ISubVault
{
    using SafeERC20 for IERC20;

    /// @dev Role definitions
    bytes32 public constant ADMIN_ROLE = keccak256('ADMIN_ROLE');

    /// @notice Core contract references
    address public router;

    /// @notice ZTLN Prime token address
    /// @dev Immutable-like variable in upgradeable contract
    address public ztlnPrime;

    /// @notice Asset management mappings
    /// @dev Tracks ZTLN Prime and secondary assets
    mapping(address => bool) public supportedAssets;
    address[] private _supportedAssetsList;

    /// @notice Emergency control settings
    uint256 public constant EMERGENCY_DELAY = 6 minutes;
    uint256 public lastEmergencyAction;
    bool public emergencyMode;

    /// @notice Price oracle mapping
    /// @dev Maps assets to their respective price oracles
    mapping(address => address) public assetOracles;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    /**
     * @notice Initializes the vault
     * @dev Sets up initial configuration for the upgradeable contract
     * @param _ztlnPrime Address of ZTLN Prime token
     * @param _router Address of router contract
     * @param _admin Address of initial admin
     */
    function initialize(address _ztlnPrime, address _router, address _admin) external initializer {
        require(_ztlnPrime != address(0), 'Invalid ZTLN Prime');
        require(_router != address(0), 'Invalid router');
        require(_admin != address(0), 'Invalid admin');

        __AccessControl_init();
        __Pausable_init();
        __ReentrancyGuard_init();
        __UUPSUpgradeable_init();

        _grantRole(DEFAULT_ADMIN_ROLE, _admin);
        _grantRole(ADMIN_ROLE, _admin);
        _setRoleAdmin(ADMIN_ROLE, DEFAULT_ADMIN_ROLE);

        ztlnPrime = _ztlnPrime;
        router = _router;

        // Set up ZTLN Prime as primary asset
        supportedAssets[_ztlnPrime] = true;
        _supportedAssetsList.push(_ztlnPrime);

        emit AssetAdded(_ztlnPrime, 'ZTLN Prime configured as primary asset');
    }

    /// @notice Ensures caller is authorized router
    modifier onlyRouter() {
        if (msg.sender != router) revert UnauthorizedCaller(msg.sender);
        _;
    }

    /// @notice Ensures address is not zero
    modifier validAddress(address addr) {
        if (addr == address(0)) revert InvalidAddress(addr);
        _;
    }

    // Add router setup function
    /// @notice Sets the router address
    /// @param _router Address of the router contract
    /// @dev Can only be set once by admin
    function setRouter(address _router) external onlyRole(ADMIN_ROLE) validAddress(_router) {
        router = _router;
        emit RouterSet(_router);
    }

    // Function to set oracle for an asset
    function setAssetOracle(address asset, address oracle) external onlyRole(ADMIN_ROLE) {
        require(asset != address(0), 'Invalid asset address');
        require(oracle != address(0), 'Invalid oracle address');
        assetOracles[asset] = oracle;
        emit AssetOracleSet(asset, oracle);
    }

    /// @notice Gets the oracle price for a supported asset
    /// @param asset Address of the asset to get price for
    /// @return price Current oracle price converted to uint256
    /// @return success Whether oracle price was successfully fetched
    function getOraclePrice(
        address asset
    ) external view override returns (uint256 price, bool success) {
        if (!supportedAssets[asset]) {
            return (0, false);
        }

        address oracle = assetOracles[asset];
        if (oracle == address(0)) {
            return (0, false);
        }

        try IPriceOracle(oracle).latestRoundData() returns (
            uint80 /*roundId*/,
            int256 answer,
            uint256 /*startedAt*/,
            uint256 updatedAt,
            uint80 /*answeredInRound*/
        ) {
            // Check if the price is positive
            if (answer <= 0) {
                return (0, false);
            }

            // Check for stale price
            if (block.timestamp - updatedAt > 24 hours) {
                // Configure timeout as needed
                return (0, false);
            }

            return (uint256(answer), true);
        } catch {
            return (0, false);
        }
    }

    /// @notice Handles deposit of supported assets
    /// @dev Routes to ZTLN Prime or secondary asset handling
    /// @param user Address of depositing user
    /// @param asset Address of asset being deposited
    /// @param amount Amount to deposit
    /// @return success Whether deposit was successful
    function handleDeposit(
        address user,
        address asset,
        uint256 amount
    ) external override nonReentrant onlyRouter whenNotPaused returns (bool) {
        if (!supportedAssets[asset]) revert UnsupportedAsset(asset);
        if (amount == 0) revert InvalidAmount();
        if (emergencyMode) revert EmergencyModeEnabled(block.timestamp);

        _revokeApproval(asset, address(ztlnPrime));
        _grantApproval(asset, address(ztlnPrime), amount);

        try IFundVaultV2(ztlnPrime).deposit(asset, amount) returns (uint256) {
            emit SecondaryAssetOperation(asset, user, amount, true);
            return true;
        } catch Error(string memory reason) {
            _revokeApproval(asset, address(ztlnPrime));
            revert SecondaryAssetOperationFailed(reason);
        }
    }

    /// @notice Handles withdrawal of supported assets
    /// @dev Routes to ZTLN Prime or secondary asset handling
    /// @param user Address of withdrawing user
    /// @param asset Address of asset being withdrawn
    /// @param amount Amount to withdraw
    /// @return success Whether withdrawal was successful
    function handleWithdraw(
        address user,
        address asset,
        uint256 amount
    ) external override nonReentrant onlyRouter whenNotPaused returns (bool) {
        if (!supportedAssets[asset]) revert UnsupportedAsset(asset);
        if (amount == 0) revert InvalidAmount();
        if (emergencyMode) revert EmergencyModeEnabled(block.timestamp);

        if (asset == ztlnPrime) {
            return _handleZTLNWithdraw(user, amount);
        } else {
            return _handleSecondaryAssetWithdraw(user, asset, amount);
        }
    }

    /// @notice Internal handler for ZTLN Prime withdrawals
    /// @dev Withdraws ZTLN Prime from FundVaultV2
    /// @param user User receiving withdrawal
    /// @param amount Amount being withdrawn
    /// @return success Whether operation succeeded
    function _handleZTLNWithdraw(address user, uint256 amount) internal returns (bool) {
        IERC20(ztlnPrime).safeTransfer(user, amount);
        emit PrimaryAssetOperation(user, amount, false);
        return true;
    }

    /// @notice Internal handler for secondary asset withdrawals
    /// @dev Handles non-ZTLN Prime token withdrawals
    /// @param user User receiving withdrawal
    /// @param asset Asset being withdrawn
    /// @param amount Amount being withdrawn
    /// @return success Whether operation succeeded
    function _handleSecondaryAssetWithdraw(
        address user,
        address asset,
        uint256 amount
    ) internal returns (bool) {
        try IFundVaultV2(ztlnPrime).redeem(amount, asset) returns (uint256 withdrawnAmount) {
            emit SecondaryAssetOperation(ztlnPrime, user, withdrawnAmount, false);
            return true;
        } catch Error(string memory reason) {
            revert PrimaryAssetOperationFailed(reason);
        }
    }

    /// @notice Adds support for a secondary asset
    /// @dev Cannot add ZTLN Prime as it's already primary
    /// @param asset Asset address to add
    /// @param reason Reason for adding support
    function addAsset(
        address asset,
        string calldata reason
    ) external override onlyRole(ADMIN_ROLE) validAddress(asset) {
        if (asset == ztlnPrime) revert AssetAlreadySupported(asset);
        if (supportedAssets[asset]) revert AssetAlreadySupported(asset);

        supportedAssets[asset] = true;
        _supportedAssetsList.push(asset);
        emit AssetAdded(asset, reason);
    }

    /// @notice Removes support for a secondary asset
    /// @dev Cannot remove ZTLN Prime
    /// @param asset Asset address to remove
    /// @param reason Reason for removal
    function removeAsset(
        address asset,
        string calldata reason
    ) external override onlyRole(ADMIN_ROLE) {
        if (asset == ztlnPrime) revert CannotRemovePrimaryAsset();
        if (!supportedAssets[asset]) revert UnsupportedAsset(asset);

        uint256 length = _supportedAssetsList.length;
        uint256 assetIndex = type(uint256).max;

        for (uint256 i = 0; i < length; i++) {
            if (_supportedAssetsList[i] == asset) {
                assetIndex = i;
                break;
            }
        }

        require(assetIndex != type(uint256).max, 'Asset not found');

        if (assetIndex != length - 1) {
            _supportedAssetsList[assetIndex] = _supportedAssetsList[length - 1];
        }
        _supportedAssetsList.pop();

        emit AssetRemoved(asset, reason);
    }

    /// @notice Enables emergency mode
    /// @dev Pauses operations and starts emergency timer
    function enableEmergencyMode() external override onlyRole(ADMIN_ROLE) whenNotPaused {
        emergencyMode = true;
        _pause();
        lastEmergencyAction = block.timestamp;
        emit EmergencyModeSet(block.timestamp, true);
    }

    /// @notice Disables emergency mode
    /// @dev Requires emergency delay to have passed
    function disableEmergencyMode() external override onlyRole(ADMIN_ROLE) {
        if (block.timestamp < lastEmergencyAction + EMERGENCY_DELAY)
            revert EmergencyDelayNotPassed();
        _unpause();
        emergencyMode = false;
        emit EmergencyModeSet(block.timestamp, false);
    }

    /// @notice Executes emergency withdrawal
    /// @dev Available only in emergency mode after delay
    /// @param asset Asset to withdraw
    /// @param to Recipient address
    /// @param amount Amount to withdraw
    /// @param reason Reason for withdrawal
    /// @return success Whether withdrawal succeeded
    function withdrawEmergency(
        address asset,
        address to,
        uint256 amount,
        string calldata reason
    ) external override nonReentrant onlyRole(ADMIN_ROLE) returns (bool) {
        if (!emergencyMode) revert EmergencyModeNotEnabled();
        if (block.timestamp < lastEmergencyAction + EMERGENCY_DELAY)
            revert EmergencyDelayNotPassed();
        if (amount == 0) revert InvalidAmount();
        if (!supportedAssets[asset]) revert UnsupportedAsset(asset);

        uint256 balance = IERC20(asset).balanceOf(address(this));
        uint256 withdrawAmount = amount > balance ? balance : amount;

        if (asset == ztlnPrime) {
            // Special handling for ZTLN Prime emergency withdrawal
            _revokeApproval(ztlnPrime, address(ztlnPrime));
        }

        IERC20(asset).safeTransfer(to, withdrawAmount);

        lastEmergencyAction = block.timestamp;
        emit EmergencyWithdrawalExecuted(asset, to, withdrawAmount, reason);

        return true;
    }

    /// @notice Pauses vault operations
    /// @dev Admin only function
    function pause() external override onlyRole(ADMIN_ROLE) {
        _pause();
    }

    /// @notice Unpauses vault operations
    /// @dev Cannot unpause in emergency mode
    function unpause() external override onlyRole(ADMIN_ROLE) {
        if (emergencyMode) revert EmergencyModeEnabled(block.timestamp);
        _unpause();
    }

    /// @notice Grants approval for asset spending
    /// @dev Internal function for managing approvals
    /// @param asset Asset to approve
    /// @param spender Address to approve
    /// @param amount Amount to approve
    function _grantApproval(address asset, address spender, uint256 amount) internal {
        try IERC20(asset).approve(spender, amount) {
            emit ApprovalGranted(asset, spender, amount);
        } catch {
            revert ApprovalFailed(asset, spender);
        }
    }

    /// @notice Revokes approval for asset spending
    /// @dev Internal function for managing approvals
    /// @param asset Asset to revoke approval for
    /// @param spender Address to revoke approval from
    function _revokeApproval(address asset, address spender) internal {
        try IERC20(asset).approve(spender, 0) {
            emit ApprovalRevoked(asset, spender);
        } catch {
            revert ApprovalFailed(asset, spender);
        }
    }

    // View Functions

    /// @notice Gets list of supported assets
    /// @return Array of supported asset addresses
    function getSupportedAssets() external view override returns (address[] memory) {
        return _supportedAssetsList;
    }

    /// @notice Gets true for supported assets
    /// @return Whether the asset is supported
    function isAssetSupported(address asset) external view override returns (bool) {
        return supportedAssets[asset];
    }

    /// @notice Gets emergency status details
    /// @return isEmergencyMode Whether emergency mode is active
    /// @return isPaused Whether operations are paused
    /// @return timeUntilNextAction Time until next emergency action
    function getEmergencyStatus()
        external
        view
        override
        returns (bool isEmergencyMode, bool isPaused, uint256 timeUntilNextAction)
    {
        uint256 nextActionTime = lastEmergencyAction + EMERGENCY_DELAY;
        uint256 timeUntil = block.timestamp >= nextActionTime
            ? 0
            : nextActionTime - block.timestamp;

        return (emergencyMode, paused(), timeUntil);
    }

    /// @notice Checks if asset is ZTLN Prime
    /// @param asset Asset to check
    /// @return bool Whether asset is ZTLN Prime
    function isPrimaryAsset(address asset) external view override returns (bool) {
        return asset == ztlnPrime;
    }

    /// @notice Gets ZTLN Prime address
    /// @return address ZTLN Prime token address
    function getPrimaryAsset() external view override returns (address) {
        return ztlnPrime;
    }

    /// @notice Gets total supported assets count
    /// @return uint256 Number of supported assets (including ZTLN Prime)
    function getSupportedAssetsCount() external view returns (uint256) {
        return _supportedAssetsList.length;
    }

    /// @notice Gets ZTLN Prime balance
    /// @dev Returns the vault's ZTLN Prime balance
    /// @return uint256 ZTLN Prime balance
    function getZTLNBalance() external view returns (uint256) {
        return IERC20(ztlnPrime).balanceOf(address(this));
    }

    /// @notice Checks if operations are possible
    /// @dev Combines emergency and pause status
    /// @return bool Whether operations are possible
    function isOperational() external view returns (bool) {
        return !paused() && !emergencyMode;
    }

    /// @notice Gets vault statistics
    /// @dev Returns key vault metrics
    /// @return ztlnBalance Current ZTLN Prime balance
    /// @return secondaryAssetCount Number of secondary assets
    /// @return isActive Whether vault is active
    function getVaultStats()
        external
        view
        returns (uint256 ztlnBalance, uint256 secondaryAssetCount, bool isActive)
    {
        return (
            IERC20(ztlnPrime).balanceOf(address(this)),
            _supportedAssetsList.length - 1, // Subtract 1 for ZTLN Prime
            !paused() && !emergencyMode
        );
    }

    /// @notice Authorizes contract upgrades
    /// @param newImplementation Address of new implementation
    /// @dev Only callable by DEFAULT_ADMIN_ROLE
    function _authorizeUpgrade(
        address newImplementation
    ) internal override onlyRole(DEFAULT_ADMIN_ROLE) {}
}

File 2 of 27 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @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:
 *
 * ```solidity
 * 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}:
 *
 * ```solidity
 * 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. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;


    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
    struct AccessControlStorage {
        mapping(bytes32 role => RoleData) _roles;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;

    function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
        assembly {
            $.slot := AccessControlStorageLocation
        }
    }

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    function __AccessControl_init() internal onlyInitializing {
    }

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

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

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @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 virtual returns (bytes32) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        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.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual 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.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual 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 revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

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

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (!hasRole(role, account)) {
            $._roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (hasRole(role, account)) {
            $._roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

File 3 of 27 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @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 proxied contracts do not make use of 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.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

File 4 of 27 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.20;

import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable __self = address(this);

    /**
     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
     * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
     * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
     * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
     * during an upgrade.
     */
    string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";

    /**
     * @dev The call is from an unauthorized context.
     */
    error UUPSUnauthorizedCallContext();

    /**
     * @dev The storage `slot` is unsupported as a UUID.
     */
    error UUPSUnsupportedProxiableUUID(bytes32 slot);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        _checkProxy();
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        _checkNotDelegated();
        _;
    }

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual notDelegated returns (bytes32) {
        return ERC1967Utils.IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data);
    }

    /**
     * @dev Reverts if the execution is not performed via delegatecall or the execution
     * context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
     * See {_onlyProxy}.
     */
    function _checkProxy() internal view virtual {
        if (
            address(this) == __self || // Must be called through delegatecall
            ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
        ) {
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Reverts if the execution is performed via delegatecall.
     * See {notDelegated}.
     */
    function _checkNotDelegated() internal view virtual {
        if (address(this) != __self) {
            // Must not be called through delegatecall
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
     *
     * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
     * is expected to be the implementation slot in ERC-1967.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
        try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
            if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
                revert UUPSUnsupportedProxiableUUID(slot);
            }
            ERC1967Utils.upgradeToAndCall(newImplementation, data);
        } catch {
            // The implementation is not UUPS
            revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
        }
    }
}

File 5 of 27 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

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

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 6 of 27 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 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);
 * }
 * ```
 */
abstract contract ERC165Upgradeable is Initializable, IERC165 {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 7 of 27 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../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 {
    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable
    struct PausableStorage {
        bool _paused;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;

    function _getPausableStorage() private pure returns (PausableStorage storage $) {
        assembly {
            $.slot := PausableStorageLocation
        }
    }

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

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

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

    function __Pausable_init_unchained() internal onlyInitializing {
        PausableStorage storage $ = _getPausableStorage();
        $._paused = false;
    }

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        PausableStorage storage $ = _getPausableStorage();
        $._paused = false;
        emit Unpaused(_msgSender());
    }
}

File 8 of 27 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
    struct ReentrancyGuardStorage {
        uint256 _status;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
        assembly {
            $.slot := ReentrancyGuardStorageLocation
        }
    }

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        $._status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if ($._status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        $._status = ENTERED;
    }

    function _nonReentrantAfter() private {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        $._status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        return $._status == ENTERED;
    }
}

File 9 of 27 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC-165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @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.
     */
    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. This account bears the admin role (for the granted role).
     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
     */
    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 Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

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

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

    /**
     * @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 `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

File 10 of 27 : draft-IERC1822.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.20;

/**
 * @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822Proxiable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 11 of 27 : IERC1363.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

File 12 of 27 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";

File 13 of 27 : IERC1967.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)

pragma solidity ^0.8.20;

/**
 * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
 */
interface IERC1967 {
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Emitted when the beacon is changed.
     */
    event BeaconUpgraded(address indexed beacon);
}

File 14 of 27 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";

File 15 of 27 : IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {UpgradeableBeacon} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 16 of 27 : ERC1967Utils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Utils.sol)

pragma solidity ^0.8.21;

import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";

/**
 * @dev This library provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
 */
library ERC1967Utils {
    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev The `implementation` of the proxy is invalid.
     */
    error ERC1967InvalidImplementation(address implementation);

    /**
     * @dev The `admin` of the proxy is invalid.
     */
    error ERC1967InvalidAdmin(address admin);

    /**
     * @dev The `beacon` of the proxy is invalid.
     */
    error ERC1967InvalidBeacon(address beacon);

    /**
     * @dev An upgrade function sees `msg.value > 0` that may be lost.
     */
    error ERC1967NonPayable();

    /**
     * @dev Returns the current implementation address.
     */
    function getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the ERC-1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(newImplementation);
        }
        StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Performs implementation upgrade with additional setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) internal {
        _setImplementation(newImplementation);
        emit IERC1967.Upgraded(newImplementation);

        if (data.length > 0) {
            Address.functionDelegateCall(newImplementation, data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the ERC-1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        if (newAdmin == address(0)) {
            revert ERC1967InvalidAdmin(address(0));
        }
        StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {IERC1967-AdminChanged} event.
     */
    function changeAdmin(address newAdmin) internal {
        emit IERC1967.AdminChanged(getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the ERC-1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        if (newBeacon.code.length == 0) {
            revert ERC1967InvalidBeacon(newBeacon);
        }

        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;

        address beaconImplementation = IBeacon(newBeacon).implementation();
        if (beaconImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(beaconImplementation);
        }
    }

    /**
     * @dev Change the beacon and trigger a setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-BeaconUpgraded} event.
     *
     * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
     * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
     * efficiency.
     */
    function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
        _setBeacon(newBeacon);
        emit IERC1967.BeaconUpgraded(newBeacon);

        if (data.length > 0) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
     * if an upgrade doesn't perform an initialization call.
     */
    function _checkNonPayable() private {
        if (msg.value > 0) {
            revert ERC1967NonPayable();
        }
    }
}

File 17 of 27 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

File 18 of 27 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 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 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

File 19 of 27 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

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

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert Errors.FailedCall();
        }
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
     * of an unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {Errors.FailedCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            assembly ("memory-safe") {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}

File 20 of 27 : Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedCall();

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}

File 21 of 27 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC 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 22 of 27 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC-1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct Int256Slot {
        int256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `Int256Slot` with member `value` located at `slot`.
     */
    function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns a `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns a `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        assembly ("memory-safe") {
            r.slot := store.slot
        }
    }
}

File 23 of 27 : ISubVaultErrors.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

/// @title SubVault Errors Interface
/// @notice Custom errors for subvault operations
/// @dev All possible errors that can be thrown by SubVault
interface ISubVaultErrors {
    /// @notice Thrown when caller is not authorized
    /// @param caller Address of unauthorized caller
    error UnauthorizedCaller(address caller);

    /// @notice Thrown when asset operation is unsupported
    /// @param asset Address of unsupported asset
    error UnsupportedAsset(address asset);

    /// @notice Thrown when asset is already configured
    /// @param asset Address of already supported asset
    error AssetAlreadySupported(address asset);

    /// @notice Thrown when address is invalid (usually zero)
    /// @param addr The invalid address
    error InvalidAddress(address addr);

    /// @notice Thrown when amount is invalid (usually zero)
    error InvalidAmount();

    /// @notice Thrown when deposit operation fails
    /// @param reason Description of failure
    error DepositFailed(string reason);

    /// @notice Thrown when withdrawal operation fails
    /// @param reason Description of failure
    error WithdrawFailed(string reason);

    /// @notice Thrown when emergency delay period hasn't passed
    error EmergencyDelayNotPassed();

    /// @notice Thrown when emergency mode is active
    /// @param timestamp Time when emergency mode was enabled
    error EmergencyModeEnabled(uint256 timestamp);

    /// @notice Thrown when emergency mode is not active
    error EmergencyModeNotEnabled();

    /// @notice Thrown when balance is insufficient
    /// @param requested Amount requested
    /// @param available Amount available
    error InsufficientBalance(uint256 requested, uint256 available);

    /// @notice Thrown when approval operation fails
    /// @param asset Asset for which approval failed
    /// @param spender Address that was to be approved
    error ApprovalFailed(address asset, address spender);

    /// @notice Thrown when attempting to remove primary asset
    error CannotRemovePrimaryAsset();

    /// @notice Thrown when primary asset operation fails
    /// @param reason Description of failure
    error PrimaryAssetOperationFailed(string reason);

    /// @notice Thrown when secondary asset operation fails
    /// @param reason Description of failure
    error SecondaryAssetOperationFailed(string reason);
}

File 24 of 27 : ISubVaultEvents.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

/// @title SubVault Events Interface
/// @notice Events emitted by subvault operations
/// @dev All events that can be emitted by SubVault
interface ISubVaultEvents {
    /// @notice Emitted when router address is set
    /// @param router Address of the newly set router contract
    /// @dev Router can only be set once and is critical for deposit operations
    event RouterSet(address indexed router);

    event AssetOracleSet(address indexed asset, address indexed oracle);
    /// @notice Emitted when an asset is added to supported assets
    /// @param asset Address of added asset
    /// @param reason Reason for adding
    event AssetAdded(address indexed asset, string reason);

    /// @notice Emitted when an asset is removed from supported assets
    /// @param asset Address of removed asset
    /// @param reason Reason for removal
    event AssetRemoved(address indexed asset, string reason);

    /// @notice Emitted when a deposit is processed
    /// @param user User who deposited
    /// @param asset Asset deposited
    /// @param amount Amount deposited
    /// @param shares Shares minted
    event DepositProcessed(
        address indexed user,
        address indexed asset,
        uint256 amount,
        uint256 shares
    );

    /// @notice Emitted when a withdrawal is processed
    /// @param user User who withdrew
    /// @param asset Asset withdrawn
    /// @param amount Amount withdrawn
    event WithdrawProcessed(address indexed user, address indexed asset, uint256 amount);

    /// @notice Emitted when emergency withdrawal is executed
    /// @param asset Asset withdrawn
    /// @param to Recipient address
    /// @param amount Amount withdrawn
    /// @param reason Reason for withdrawal
    event EmergencyWithdrawalExecuted(
        address indexed asset,
        address indexed to,
        uint256 amount,
        string reason
    );

    /// @notice Emitted when emergency mode status changes
    /// @param timestamp Time of change
    /// @param enabled New status
    event EmergencyModeSet(uint256 timestamp, bool enabled);

    /// @notice Emitted when admin role changes
    /// @param oldAdmin Previous admin address
    /// @param newAdmin New admin address
    event AdminChanged(address indexed oldAdmin, address indexed newAdmin);

    /// @notice Emitted when approval is granted
    /// @param asset Asset approved
    /// @param spender Address approved to spend
    /// @param amount Amount approved
    event ApprovalGranted(address indexed asset, address indexed spender, uint256 amount);

    /// @notice Emitted when approval is revoked
    /// @param asset Asset for which approval was revoked
    /// @param spender Address whose approval was revoked
    event ApprovalRevoked(address indexed asset, address indexed spender);

    /// @notice Emitted when primary asset operation occurs
    /// @param user User involved in operation
    /// @param amount Amount involved
    /// @param isDeposit Whether operation was deposit
    event PrimaryAssetOperation(address indexed user, uint256 amount, bool isDeposit);

    /// @notice Emitted when secondary asset operation occurs
    /// @param asset Secondary asset involved
    /// @param user User involved in operation
    /// @param amount Amount involved
    /// @param isDeposit Whether operation was deposit
    event SecondaryAssetOperation(
        address indexed asset,
        address indexed user,
        uint256 amount,
        bool isDeposit
    );
}

File 25 of 27 : IFundVaultV2.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

interface IFundVaultV2 {
    function deposit(address asset, uint256 amount) external returns (uint256 shares);

    function redeem(uint256 shares, address asset) external returns (uint256 amount);
}

File 26 of 27 : IPriceOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IPriceOracle {
    function latestRoundData()
        external
        view
        returns (
            uint80 roundId,
            int256 answer,
            uint256 startedAt,
            uint256 updatedAt,
            uint80 answeredInRound
        );
}

File 27 of 27 : ISubVault.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;

import '../events/ISubVaultEvents.sol';
import '../errors/ISubVaultErrors.sol';

/// @title Asset Specific SubVault Interface
/// @notice Interface for specialized vaults handling primary and secondary assets
/// @dev Implements deposit/withdrawal functionality with primary asset focus
/// @custom:security-contact [email protected]
interface ISubVault is ISubVaultEvents, ISubVaultErrors {
    /// @notice SECURITY CONSIDERATIONS:
    /// - Primary asset operations must be validated separately
    /// - Secondary assets require additional validation
    /// - Balance checks before all operations
    /// - Emergency mode restrictions
    /// - Proper approval management for FundVaultV2
    /// - Asset-specific transfer validations
    ///
    /// STATE MANAGEMENT:
    /// - Normal: Full functionality for all assets
    /// - Paused: No operations allowed
    /// - Emergency: Only emergency withdrawals
    /// - Primary Asset: Always supported
    /// - Secondary Assets: Can be added/removed
    ///
    /// INTEGRATION REQUIREMENTS:
    /// - Must validate primary asset operations first
    /// - Must implement separate flows for primary/secondary assets
    /// - Must maintain accurate balances for all assets
    /// - Must emit appropriate events for tracking
    /// - Must handle FundVaultV2 interactions safely
    /// - Must implement proper access control
    ///
    /// ASSET HANDLING:
    /// Primary Asset:
    /// - Cannot be removed
    /// - Direct integration with FundVaultV2
    /// - Specialized event emission
    ///
    /// Secondary Assets:
    /// - Can be added/removed by admin
    /// - May require conversion logic
    /// - Separate event emission

    /// @notice Handles deposit of any supported asset
    /// @param user Address of the depositing user
    /// @param asset Address of the asset being deposited
    /// @param amount Amount to deposit
    /// @return success Whether the deposit was successful
    /// @dev Different handling for primary vs secondary assets
    function handleDeposit(address user, address asset, uint256 amount) external returns (bool);

    /// @notice Handles withdrawal of any supported asset
    /// @param user Address of the withdrawing user
    /// @param asset Address of the asset to withdraw
    /// @param amount Amount to withdraw
    /// @return success Whether the withdrawal was successful
    /// @dev Different handling for primary vs secondary assets
    function handleWithdraw(address user, address asset, uint256 amount) external returns (bool);

    /// @notice Gets the current oracle price for the asset if available
    /// @param asset Address of the asset to get price for
    /// @return price Current oracle price (0 if not available)
    /// @return success Whether oracle price was successfully fetched
    function getOraclePrice(address asset) external view returns (uint256 price, bool success);

    /// @notice Executes emergency withdrawal for any supported asset
    /// @param asset Address of the asset to withdraw
    /// @param to Recipient address
    /// @param amount Amount to withdraw
    /// @param reason Reason for emergency withdrawal
    /// @return success Whether the withdrawal was successful
    /// @dev Available in emergency mode only, special handling for primary asset
    function withdrawEmergency(
        address asset,
        address to,
        uint256 amount,
        string calldata reason
    ) external returns (bool);

    /// @notice Adds support for a secondary asset
    /// @param asset Address of the asset to add
    /// @param reason Reason for adding the asset
    /// @dev Cannot add primary asset, reverts if asset already supported
    function addAsset(address asset, string calldata reason) external;

    /// @notice Removes support for a secondary asset
    /// @param asset Address of the asset to remove
    /// @param reason Reason for removing the asset
    /// @dev Cannot remove primary asset, reverts if asset not supported
    function removeAsset(address asset, string calldata reason) external;

    /// @notice Gets complete list of supported assets
    /// @return Array of supported asset addresses
    /// @dev Primary asset is always first in the array
    function getSupportedAssets() external view returns (address[] memory);

    /// @notice Gets true for supported asset
    /// @param asset Address of the asset to check
    /// @return Whether the asset is supported
    function isAssetSupported(address asset) external view returns (bool);

    /// @notice Gets current emergency status
    /// @return isEmergencyMode Whether emergency mode is active
    /// @return isPaused Whether vault is paused
    /// @return timeUntilNextAction Time until next emergency action allowed
    /// @dev Used to check vault status before operations
    function getEmergencyStatus()
        external
        view
        returns (bool isEmergencyMode, bool isPaused, uint256 timeUntilNextAction);

    /// @notice Checks if an asset is the primary asset
    /// @param asset Asset address to check
    /// @return bool True if asset is primary asset
    /// @dev Used to determine asset handling flow
    function isPrimaryAsset(address asset) external view returns (bool);

    /// @notice Gets the primary asset address
    /// @return address Address of primary asset
    /// @dev Primary asset cannot be changed after deployment
    function getPrimaryAsset() external view returns (address);

    /// @notice Enables emergency mode
    /// @dev Pauses operations and starts emergency delay timer
    function enableEmergencyMode() external;

    /// @notice Disables emergency mode
    /// @dev Can only be called after emergency delay period
    function disableEmergencyMode() external;

    /// @notice Pauses all vault operations
    /// @dev Separate from emergency mode
    function pause() external;

    /// @notice Unpauses vault operations
    /// @dev Cannot unpause if in emergency mode
    function unpause() external;
}

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

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"ApprovalFailed","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"AssetAlreadySupported","type":"error"},{"inputs":[],"name":"CannotRemovePrimaryAsset","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"DepositFailed","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"EmergencyDelayNotPassed","type":"error"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"EmergencyModeEnabled","type":"error"},{"inputs":[],"name":"EmergencyModeNotEnabled","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"requested","type":"uint256"},{"internalType":"uint256","name":"available","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"PrimaryAssetOperationFailed","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"SecondaryAssetOperationFailed","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"UnauthorizedCaller","type":"error"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"UnsupportedAsset","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"WithdrawFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ApprovalGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"}],"name":"ApprovalRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"AssetAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"}],"name":"AssetOracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"AssetRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"DepositProcessed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"EmergencyModeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"EmergencyWithdrawalExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isDeposit","type":"bool"}],"name":"PrimaryAssetOperation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"router","type":"address"}],"name":"RouterSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isDeposit","type":"bool"}],"name":"SecondaryAssetOperation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawProcessed","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EMERGENCY_DELAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"string","name":"reason","type":"string"}],"name":"addAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assetOracles","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableEmergencyMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyMode","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enableEmergencyMode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getEmergencyStatus","outputs":[{"internalType":"bool","name":"isEmergencyMode","type":"bool"},{"internalType":"bool","name":"isPaused","type":"bool"},{"internalType":"uint256","name":"timeUntilNextAction","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getOraclePrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrimaryAsset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSupportedAssetsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVaultStats","outputs":[{"internalType":"uint256","name":"ztlnBalance","type":"uint256"},{"internalType":"uint256","name":"secondaryAssetCount","type":"uint256"},{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getZTLNBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"handleDeposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"handleWithdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ztlnPrime","type":"address"},{"internalType":"address","name":"_router","type":"address"},{"internalType":"address","name":"_admin","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"isAssetSupported","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isOperational","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"isPrimaryAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastEmergencyAction","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"string","name":"reason","type":"string"}],"name":"removeAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"oracle","type":"address"}],"name":"setAssetOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"name":"setRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedAssets","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"reason","type":"string"}],"name":"withdrawEmergency","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ztlnPrime","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b60405161278990816100f0823960805181818161137b015261144f0152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a7146118ad57508063085e4f65146118245780630905f56014611801578063248a9ca3146117db5780632b663986146117995780632f2ff15d1461176857806330ca2ca21461173357806336568abe146116ed5780633f4ba83a1461165c578063464b415814610e435780634f1ef286146113d257806352d1902d146113685780635a109d1d146112935780635c975abb1461126357806362adfe7a1461115a578063686258071461113c578063726e50b71461111e57806375b238fc146110f557806375f620ac146110c45780637e97470014610f9457806382944e2d146110a75780638456cb591461103357806391d1485414610fd9578063a217fddf14610fbd578063a57ef2c314610f94578063a59aa5a614610ec5578063ad3cb1cc14610e82578063bd81579e14610e43578063bdc631d414610e04578063c0c53b8b14610a3a578063c0d78655146109be578063c5b1c7d014610901578063cd905dff146108bc578063d0e8dcff1461084c578063d547741f14610814578063e5406dbf14610748578063eb75dc311461054f578063ef9525681461046c578063f887ea4014610443578063f901dc331461026c5763fa37273c146101e257600080fd5b346102675760003660031901126102675760045461016881018091116102515742811161023f5750606060005b60ff600554169060ff6000805160206126fd83398151915254166040519215158352151560208301526040820152f35b61024c6060914290611b86565b61020f565b634e487b7160e01b600052601160045260246000fd5b600080fd5b346102675761027a366119ae565b90610283612002565b6001546001600160a01b03938416931683146104325782600052600260205260ff604060002054161561041d5760035460001960005b8281106103ec575b5060001981146103b557600019820191821161025157818103610363575b505060035491821561034d577f9ca3f065622f5f03f32b7157677a0e420c3a36ab45fd49f256ffebce3e310587926000190161031a81611a96565b81546001600160a01b03600392831b1b19169091555560405160208082529092839261034892840191611b4e565b0390a2005b634e487b7160e01b600052603160045260246000fd5b61038a6103726103ae93611a96565b905460039190911b1c6001600160a01b031691611a96565b81546001600160a01b0393841660039290921b91821b9390911b1916919091179055565b83806102df565b60405162461bcd60e51b815260206004820152600f60248201526e105cdcd95d081b9bdd08199bdd5b99608a1b6044820152606490fd5b856103f682611a96565b905460039190911b1c6001600160a01b031614610415576001016102b9565b9050856102c1565b8263ee84f40b60e01b60005260045260246000fd5b6333fec47360e01b60005260046000fd5b34610267576000366003190112610267576000546040516001600160a01b039091168152602090f35b3461026757600036600319011261026757610485612002565b600454610168810180911161025157421061053e576000805160206126fd8339815191525460ff81161561052d5760ff19166000805160206126fd833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a160ff19600554166005557f7208c975490cec9c100544baa60b8ffe9483c88f4ef7bbd984b40cf79a3f61176040805142815260006020820152a1005b638dfc202b60e01b60005260046000fd5b6302aee1fb60e21b60005260046000fd5b3461026757608036600319011261026757610568611900565b610570611916565b6044359060643567ffffffffffffffff811161026757610594903690600401611980565b9361059d612363565b6105a5612002565b60ff600554161561073757600454610168810180911161025157421061053e578315610726576001600160a01b031660008181526002602052604090205490939060ff1615610711576040516370a0823160e01b815230600482015290602082602481885afa918215610705576000926106cc575b507f91b571fb78ef84d2ab917bcadf1f2c9fbf5c95402d7dfde1be19dfa7477b5f4993929161069491818111156106c45750915b6001546001600160a01b03168681146106b4575b5061066e83858861259b565b4260045560405193849384526040602085015260018060a01b0316966040840191611b4e565b0390a3600160008051602061271d83398151915255602060405160018152f35b806106be916123e1565b87610662565b90509161064e565b90916020823d6020116106fd575b816106e76020938361192c565b810103126106fa5750519061069461061a565b80fd5b3d91506106da565b6040513d6000823e3d90fd5b8363ee84f40b60e01b60005260045260246000fd5b63162908e360e11b60005260046000fd5b63b3ed4d6360e01b60005260046000fd5b34610267576000366003190112610267576040518060206003549283815201809260036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9060005b8181106107f557505050816107a991038261192c565b6040519182916020830190602084525180915260408301919060005b8181106107d3575050500390f35b82516001600160a01b03168452859450602093840193909201916001016107c5565b82546001600160a01b0316845260209093019260019283019201610793565b346102675760403660031901126102675761084a600435610833611916565b9061084561084082611a75565b612062565b6122c3565b005b346102675761085a36611a3b565b610865929192612363565b6000546001600160a01b031633036108a75760209261088b9261088661239f565b611f49565b600160008051602061271d833981519152556040519015158152f35b63d86ad9cf60e01b6000523360045260246000fd5b346102675760003660031901126102675760ff6000805160206126fd833981519152541615806108f4575b6020906040519015158152f35b5060055460ff16156108e7565b346102675760003660031901126102675761091a612002565b61092261239f565b600160ff19600554161760055561093761239f565b600160ff196000805160206126fd8339815191525416176000805160206126fd833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1426004557f7208c975490cec9c100544baa60b8ffe9483c88f4ef7bbd984b40cf79a3f61176040805142815260016020820152a1005b34610267576020366003190112610267576109d7611900565b6109df612002565b6001600160a01b03168015610a2657600080546001600160a01b031916821781557fc6b438e6a8a59579ce6a4406cbd203b740e0d47b458aae6596339bcd40c40d159080a2005b634726455360e11b60005260045260246000fd5b3461026757606036600319011261026757610a53611900565b610a5b611916565b6044356001600160a01b038116928382036102675760008051602061275d833981519152549360ff8560401c16159467ffffffffffffffff811680159081610dfc575b6001149081610df2575b159081610de9575b50610dd85767ffffffffffffffff19811660011760008051602061275d8339815191525585610dab575b506001600160a01b038216938415610d71576001600160a01b0316908115610d3b5715610d0657610b7d610c4093610b1061262d565b610b1861262d565b610b2061262d565b60ff196000805160206126fd83398151915254166000805160206126fd83398151915255610b4c61262d565b610b5461262d565b600160008051602061271d83398151915255610b6e61262d565b610b77816120ac565b5061215e565b5060008051602061273d83398151915260008181526000805160206126dd8339815191526020527fb16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431d80549082905590917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff8380a4836bffffffffffffffffffffffff60a01b60015416176001556bffffffffffffffffffffffff60a01b60005416176000558260005260026020526040600020600160ff19825416179055611ac7565b7ffd288a46d080f2a24ab4d47d4231a7ae3a4538d57a6c1c9afe6807e6c949f6ea608060405160208152602660208201527f5a544c4e205072696d6520636f6e66696775726564206173207072696d61727960408201526508185cdcd95d60d21b6060820152a2610cad57005b68ff00000000000000001960008051602061275d833981519152541660008051602061275d833981519152557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b60405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b21030b236b4b760991b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b2103937baba32b960911b6044820152606490fd5b60405162461bcd60e51b8152602060048201526012602482015271496e76616c6964205a544c4e205072696d6560701b6044820152606490fd5b68ffffffffffffffffff1916680100000000000000011760008051602061275d8339815191525585610ada565b63f92ee8a960e01b60005260046000fd5b90501587610ab0565b303b159150610aa8565b879150610a9e565b3461026757610e1236611a3b565b610e1d929192612363565b6000546001600160a01b031633036108a75760209261088b92610e3e61239f565b611d25565b34610267576020366003190112610267576001600160a01b03610e64611900565b166000526002602052602060ff604060002054166040519015158152f35b3461026757600036600319011261026757610ec16040805190610ea5818361192c565b60058252640352e302e360dc1b602083015251918291826119f2565b0390f35b34610267576000366003190112610267576001546040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa90811561070557600091610f62575b506003546000198101919082116102515760609160ff6000805160206126fd8339815191525416159081610f54575b604051928352602083015215156040820152f35b60055460ff16159150610f40565b90506020813d602011610f8c575b81610f7d6020938361192c565b81010312610267575181610f11565b3d9150610f70565b34610267576000366003190112610267576001546040516001600160a01b039091168152602090f35b3461026757600036600319011261026757602060405160008152f35b3461026757604036600319011261026757610ff2611916565b6004356000526000805160206126dd83398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b346102675760003660031901126102675761104c612002565b61105461239f565b600160ff196000805160206126fd8339815191525416176000805160206126fd833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346102675760003660031901126102675760206040516101688152f35b346102675760203660031901126102675760406110e76110e2611900565b611b93565b825191825215156020820152f35b3461026757600036600319011261026757602060405160008051602061273d8339815191528152f35b34610267576000366003190112610267576020600454604051908152f35b34610267576000366003190112610267576020600354604051908152f35b3461026757604036600319011261026757611173611900565b61117b611916565b90611184612002565b6001600160a01b0316908115611226576001600160a01b03169081156111e857600081815260066020526040812080546001600160a01b031916841790557fc9065e48c4acfd7b02d146dc4f3c53162e1bae95e203fbb6ed45b4ec2ed6525a9080a3005b60405162461bcd60e51b8152602060048201526016602482015275496e76616c6964206f7261636c65206164647265737360501b6044820152606490fd5b60405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206173736574206164647265737360581b6044820152606490fd5b3461026757600036600319011261026757602060ff6000805160206126fd83398151915254166040519015158152f35b34610267576112a1366119ae565b91906112ab612002565b6001600160a01b038216928315611353576001546001600160a01b0316841461133e5783600052600260205260ff6040600020541661133e576113277ffd288a46d080f2a24ab4d47d4231a7ae3a4538d57a6c1c9afe6807e6c949f6ea938560005260026020526040600020600160ff19825416179055611ac7565b610348604051928392602084526020840191611b4e565b836303b6566d60e41b60005260045260246000fd5b83634726455360e11b60005260045260246000fd5b34610267576000366003190112610267577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031630036113c15760206040516000805160206126bd8339815191528152f35b63703e46dd60e11b60005260046000fd5b6040366003190112610267576113e6611900565b6024359067ffffffffffffffff821161026757366023830112156102675781600401359061141382611964565b91611421604051938461192c565b8083526020830193366024838301011161026757816000926024602093018737840101526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016308114908115611639575b506113c1573360009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff161561161f576040516352d1902d60e01b81526001600160a01b0382169390602081600481885afa600091816115eb575b506114fb5784634c9c8ce360e01b60005260045260246000fd5b806000805160206126bd8339815191528692036115d75750823b156115c3576000805160206126bd83398151915280546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251156115a8576000809161084a945190845af43d156115a0573d9161158383611964565b92611591604051948561192c565b83523d6000602085013e61265b565b60609161265b565b505050346115b257005b63b398979f60e01b60005260046000fd5b634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d602011611617575b816116076020938361192c565b81010312610267575190866114e1565b3d91506115fa565b63e2517d3f60e01b60005233600452600060245260446000fd5b6000805160206126bd833981519152546001600160a01b0316141590508461147a565b3461026757600036600319011261026757611675612002565b60ff600554166116d8576000805160206126fd8339815191525460ff81161561052d5760ff19166000805160206126fd833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b6303d3ebcd60e31b6000524260045260246000fd5b3461026757604036600319011261026757611706611916565b336001600160a01b038216036117225761084a906004356122c3565b63334bd91960e11b60005260046000fd5b3461026757602036600319011261026757602061174e611900565b6001546040516001600160a01b0392831691909216148152f35b346102675760403660031901126102675761084a600435611787611916565b9061179461084082611a75565b61221a565b34610267576020366003190112610267576001600160a01b036117ba611900565b166000526006602052602060018060a01b0360406000205416604051908152f35b346102675760203660031901126102675760206117f9600435611a75565b604051908152f35b3461026757600036600319011261026757602060ff600554166040519015158152f35b34610267576000366003190112610267576001546040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa80156107055760009061187a575b602090604051908152f35b506020813d6020116118a5575b816118946020938361192c565b81010312610267576020905161186f565b3d9150611887565b34610267576020366003190112610267576004359063ffffffff60e01b821680920361026757602091637965db0b60e01b81149081156118ef575b5015158152f35b6301ffc9a760e01b149050836118e8565b600435906001600160a01b038216820361026757565b602435906001600160a01b038216820361026757565b90601f8019910116810190811067ffffffffffffffff82111761194e57604052565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff811161194e57601f01601f191660200190565b9181601f840112156102675782359167ffffffffffffffff8311610267576020838186019501011161026757565b906040600319830112610267576004356001600160a01b038116810361026757916024359067ffffffffffffffff8211610267576119ee91600401611980565b9091565b91909160208152825180602083015260005b818110611a25575060409293506000838284010152601f8019910116010190565b8060208092870101516040828601015201611a04565b6060906003190112610267576004356001600160a01b038116810361026757906024356001600160a01b0381168103610267579060443590565b6000526000805160206126dd83398151915260205260016040600020015490565b600354811015611ab157600360005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b90600354916801000000000000000083101561194e5760018301600355600092600354811015611b3a5760039093527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90920180546001600160a01b0319166001600160a01b0390931692909217909155565b634e487b7160e01b84526032600452602484fd5b908060209392818452848401376000828201840152601f01601f1916010190565b519069ffffffffffffffffffff8216820361026757565b9190820391821161025157565b6001600160a01b031660008181526002602052604090205460ff1615611c25576000908152600660205260409020546001600160a01b03168015611c255760a060049160405192838092633fabe5a360e21b82525afa806000928392611c38575b50611c03575050600090600090565b6000821315611c2e57611c1a620151809142611b86565b11611c255790600190565b50600090600090565b5050600090600090565b9290915060a0833d60a011611c87575b81611c5560a0938361192c565b810103126106fa5750611c6782611b6f565b506020820151611c7e608060608501519401611b6f565b50919038611bf4565b3d9150611c48565b60009060033d11611c9c57565b905060046000803e60005160e01c90565b600060443d10611d14576040513d600319016004823e8051913d602484011167ffffffffffffffff841117611d1f578282019283519167ffffffffffffffff8311611d17573d84016003190185840160200111611d175750611d149291016020019061192c565b90565b949350505050565b92915050565b9260018060a01b0382169283600052600260205260ff60406000205416156107115780156107265760ff600554166116d857600154611d6d906001600160a01b0316846123e1565b60015460405163095ea7b360e01b81526001600160a01b039091166004820181905260248201839052959060208160448160008a5af19081611f1c575b50611dc857858563482b72c160e11b60005260045260245260446000fd5b909294847f481d5df0eabfe013ffde1dd3d7772e0c6048492cc6553578f6b4b42d330f37b36020604097959751878152a36001546040516311f9fbc960e21b81526001600160a01b03878116600483015260248201869052909160209183916044918391600091165af19081611eed575b50611ea75784611e47611c8f565b6308c379a014611e5d576040513d6000823e3d90fd5b611e65611cad565b80611e705750610705565b600154611ea392611e8a916001600160a01b0316906123e1565b6040516367b2add760e01b8152918291600483016119f2565b0390fd5b60408051938452600160208501529394506001600160a01b03169290917fbaef96a0f557c7f11d0e08ab509145e537c066a3e0e7d7dc139d22378f6b40b49190a3600190565b6020813d602011611f14575b81611f066020938361192c565b810103126102675751611e39565b3d9150611ef9565b611f3d9060203d602011611f42575b611f35818361192c565b8101906123c9565b611daa565b503d611f2b565b6001600160a01b03821660008181526002602052604090205491929160ff1615611fee5783156107265760ff600554166116d8576001546001600160a01b031603611fe45750604081611fc8847f51e1faf377d8e0f71a34b9ed5c587eaf8009919f820117fe196b30ebc39049e39460018060a01b036001541661259b565b8151938452600060208501526001600160a01b031692a2600190565b611d149291612487565b63ee84f40b60e01b60005260045260246000fd5b3360009081527fb16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431c602052604090205460ff161561203b57565b63e2517d3f60e01b6000523360045260008051602061273d83398151915260245260446000fd5b60008181526000805160206126dd8339815191526020908152604080832033845290915290205460ff16156120945750565b63e2517d3f60e01b6000523360045260245260446000fd5b6001600160a01b03811660009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff16612158576001600160a01b031660008181527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d60205260408120805460ff191660011790553391907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b50600090565b6001600160a01b03811660009081527fb16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431c602052604090205460ff16612158576001600160a01b031660008181527fb16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431c60205260408120805460ff1916600117905533919060008051602061273d833981519152907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b60008181526000805160206126dd833981519152602090815260408083206001600160a01b038616845290915290205460ff166122bc5760008181526000805160206126dd833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b60008181526000805160206126dd833981519152602090815260408083206001600160a01b038616845290915290205460ff16156122bc5760008181526000805160206126dd833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b600260008051602061271d833981519152541461238e57600260008051602061271d83398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206126fd83398151915254166123b857565b63d93c066560e01b60005260046000fd5b90816020910312610267575180151581036102675790565b60405163095ea7b360e01b81526001600160a01b03928316600482018190526000602483018190529094929093169260209082906044908290875af1908161246a575b50612441575063482b72c160e11b60005260045260245260446000fd5b91907f97a94ee714dc2c5c1889f6fe8e8909a95e0307c4b272c7df374bf76582099f87600080a3565b6124829060203d602011611f4257611f35818361192c565b612424565b600154604051633def417960e11b815260048101949094526001600160a01b039283166024850152909160209184916044918391600091165af160009281612567575b5061251d576124d7611c8f565b6308c379a0146124ed576040513d6000823e3d90fd5b6124f5611cad565b806125005750610705565b604051636eb276e760e11b8152908190611ea390600483016119f2565b60015460408051938452600060208501526001600160a01b039283169391909216917fbaef96a0f557c7f11d0e08ab509145e537c066a3e0e7d7dc139d22378f6b40b491a3600190565b9092506020813d602011612593575b816125836020938361192c565b81010312610267575191386124ca565b3d9150612576565b60405163a9059cbb60e01b60208083019182526001600160a01b0394909416602483015260448083019590955293815290926000916125db60648261192c565b519082855af115610705576000513d61262457506001600160a01b0381163b155b6126035750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b600114156125fc565b60ff60008051602061275d8339815191525460401c161561264a57565b631afcd79f60e31b60005260046000fd5b90612681575080511561267057805190602001fd5b63d6bda27560e01b60005260046000fd5b815115806126b3575b612692575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561268a56fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a164736f6c634300081b000a

Deployed Bytecode

0x608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a7146118ad57508063085e4f65146118245780630905f56014611801578063248a9ca3146117db5780632b663986146117995780632f2ff15d1461176857806330ca2ca21461173357806336568abe146116ed5780633f4ba83a1461165c578063464b415814610e435780634f1ef286146113d257806352d1902d146113685780635a109d1d146112935780635c975abb1461126357806362adfe7a1461115a578063686258071461113c578063726e50b71461111e57806375b238fc146110f557806375f620ac146110c45780637e97470014610f9457806382944e2d146110a75780638456cb591461103357806391d1485414610fd9578063a217fddf14610fbd578063a57ef2c314610f94578063a59aa5a614610ec5578063ad3cb1cc14610e82578063bd81579e14610e43578063bdc631d414610e04578063c0c53b8b14610a3a578063c0d78655146109be578063c5b1c7d014610901578063cd905dff146108bc578063d0e8dcff1461084c578063d547741f14610814578063e5406dbf14610748578063eb75dc311461054f578063ef9525681461046c578063f887ea4014610443578063f901dc331461026c5763fa37273c146101e257600080fd5b346102675760003660031901126102675760045461016881018091116102515742811161023f5750606060005b60ff600554169060ff6000805160206126fd83398151915254166040519215158352151560208301526040820152f35b61024c6060914290611b86565b61020f565b634e487b7160e01b600052601160045260246000fd5b600080fd5b346102675761027a366119ae565b90610283612002565b6001546001600160a01b03938416931683146104325782600052600260205260ff604060002054161561041d5760035460001960005b8281106103ec575b5060001981146103b557600019820191821161025157818103610363575b505060035491821561034d577f9ca3f065622f5f03f32b7157677a0e420c3a36ab45fd49f256ffebce3e310587926000190161031a81611a96565b81546001600160a01b03600392831b1b19169091555560405160208082529092839261034892840191611b4e565b0390a2005b634e487b7160e01b600052603160045260246000fd5b61038a6103726103ae93611a96565b905460039190911b1c6001600160a01b031691611a96565b81546001600160a01b0393841660039290921b91821b9390911b1916919091179055565b83806102df565b60405162461bcd60e51b815260206004820152600f60248201526e105cdcd95d081b9bdd08199bdd5b99608a1b6044820152606490fd5b856103f682611a96565b905460039190911b1c6001600160a01b031614610415576001016102b9565b9050856102c1565b8263ee84f40b60e01b60005260045260246000fd5b6333fec47360e01b60005260046000fd5b34610267576000366003190112610267576000546040516001600160a01b039091168152602090f35b3461026757600036600319011261026757610485612002565b600454610168810180911161025157421061053e576000805160206126fd8339815191525460ff81161561052d5760ff19166000805160206126fd833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a160ff19600554166005557f7208c975490cec9c100544baa60b8ffe9483c88f4ef7bbd984b40cf79a3f61176040805142815260006020820152a1005b638dfc202b60e01b60005260046000fd5b6302aee1fb60e21b60005260046000fd5b3461026757608036600319011261026757610568611900565b610570611916565b6044359060643567ffffffffffffffff811161026757610594903690600401611980565b9361059d612363565b6105a5612002565b60ff600554161561073757600454610168810180911161025157421061053e578315610726576001600160a01b031660008181526002602052604090205490939060ff1615610711576040516370a0823160e01b815230600482015290602082602481885afa918215610705576000926106cc575b507f91b571fb78ef84d2ab917bcadf1f2c9fbf5c95402d7dfde1be19dfa7477b5f4993929161069491818111156106c45750915b6001546001600160a01b03168681146106b4575b5061066e83858861259b565b4260045560405193849384526040602085015260018060a01b0316966040840191611b4e565b0390a3600160008051602061271d83398151915255602060405160018152f35b806106be916123e1565b87610662565b90509161064e565b90916020823d6020116106fd575b816106e76020938361192c565b810103126106fa5750519061069461061a565b80fd5b3d91506106da565b6040513d6000823e3d90fd5b8363ee84f40b60e01b60005260045260246000fd5b63162908e360e11b60005260046000fd5b63b3ed4d6360e01b60005260046000fd5b34610267576000366003190112610267576040518060206003549283815201809260036000527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b9060005b8181106107f557505050816107a991038261192c565b6040519182916020830190602084525180915260408301919060005b8181106107d3575050500390f35b82516001600160a01b03168452859450602093840193909201916001016107c5565b82546001600160a01b0316845260209093019260019283019201610793565b346102675760403660031901126102675761084a600435610833611916565b9061084561084082611a75565b612062565b6122c3565b005b346102675761085a36611a3b565b610865929192612363565b6000546001600160a01b031633036108a75760209261088b9261088661239f565b611f49565b600160008051602061271d833981519152556040519015158152f35b63d86ad9cf60e01b6000523360045260246000fd5b346102675760003660031901126102675760ff6000805160206126fd833981519152541615806108f4575b6020906040519015158152f35b5060055460ff16156108e7565b346102675760003660031901126102675761091a612002565b61092261239f565b600160ff19600554161760055561093761239f565b600160ff196000805160206126fd8339815191525416176000805160206126fd833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1426004557f7208c975490cec9c100544baa60b8ffe9483c88f4ef7bbd984b40cf79a3f61176040805142815260016020820152a1005b34610267576020366003190112610267576109d7611900565b6109df612002565b6001600160a01b03168015610a2657600080546001600160a01b031916821781557fc6b438e6a8a59579ce6a4406cbd203b740e0d47b458aae6596339bcd40c40d159080a2005b634726455360e11b60005260045260246000fd5b3461026757606036600319011261026757610a53611900565b610a5b611916565b6044356001600160a01b038116928382036102675760008051602061275d833981519152549360ff8560401c16159467ffffffffffffffff811680159081610dfc575b6001149081610df2575b159081610de9575b50610dd85767ffffffffffffffff19811660011760008051602061275d8339815191525585610dab575b506001600160a01b038216938415610d71576001600160a01b0316908115610d3b5715610d0657610b7d610c4093610b1061262d565b610b1861262d565b610b2061262d565b60ff196000805160206126fd83398151915254166000805160206126fd83398151915255610b4c61262d565b610b5461262d565b600160008051602061271d83398151915255610b6e61262d565b610b77816120ac565b5061215e565b5060008051602061273d83398151915260008181526000805160206126dd8339815191526020527fb16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431d80549082905590917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff8380a4836bffffffffffffffffffffffff60a01b60015416176001556bffffffffffffffffffffffff60a01b60005416176000558260005260026020526040600020600160ff19825416179055611ac7565b7ffd288a46d080f2a24ab4d47d4231a7ae3a4538d57a6c1c9afe6807e6c949f6ea608060405160208152602660208201527f5a544c4e205072696d6520636f6e66696775726564206173207072696d61727960408201526508185cdcd95d60d21b6060820152a2610cad57005b68ff00000000000000001960008051602061275d833981519152541660008051602061275d833981519152557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b60405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b21030b236b4b760991b6044820152606490fd5b60405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b2103937baba32b960911b6044820152606490fd5b60405162461bcd60e51b8152602060048201526012602482015271496e76616c6964205a544c4e205072696d6560701b6044820152606490fd5b68ffffffffffffffffff1916680100000000000000011760008051602061275d8339815191525585610ada565b63f92ee8a960e01b60005260046000fd5b90501587610ab0565b303b159150610aa8565b879150610a9e565b3461026757610e1236611a3b565b610e1d929192612363565b6000546001600160a01b031633036108a75760209261088b92610e3e61239f565b611d25565b34610267576020366003190112610267576001600160a01b03610e64611900565b166000526002602052602060ff604060002054166040519015158152f35b3461026757600036600319011261026757610ec16040805190610ea5818361192c565b60058252640352e302e360dc1b602083015251918291826119f2565b0390f35b34610267576000366003190112610267576001546040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa90811561070557600091610f62575b506003546000198101919082116102515760609160ff6000805160206126fd8339815191525416159081610f54575b604051928352602083015215156040820152f35b60055460ff16159150610f40565b90506020813d602011610f8c575b81610f7d6020938361192c565b81010312610267575181610f11565b3d9150610f70565b34610267576000366003190112610267576001546040516001600160a01b039091168152602090f35b3461026757600036600319011261026757602060405160008152f35b3461026757604036600319011261026757610ff2611916565b6004356000526000805160206126dd83398151915260205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b346102675760003660031901126102675761104c612002565b61105461239f565b600160ff196000805160206126fd8339815191525416176000805160206126fd833981519152557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346102675760003660031901126102675760206040516101688152f35b346102675760203660031901126102675760406110e76110e2611900565b611b93565b825191825215156020820152f35b3461026757600036600319011261026757602060405160008051602061273d8339815191528152f35b34610267576000366003190112610267576020600454604051908152f35b34610267576000366003190112610267576020600354604051908152f35b3461026757604036600319011261026757611173611900565b61117b611916565b90611184612002565b6001600160a01b0316908115611226576001600160a01b03169081156111e857600081815260066020526040812080546001600160a01b031916841790557fc9065e48c4acfd7b02d146dc4f3c53162e1bae95e203fbb6ed45b4ec2ed6525a9080a3005b60405162461bcd60e51b8152602060048201526016602482015275496e76616c6964206f7261636c65206164647265737360501b6044820152606490fd5b60405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206173736574206164647265737360581b6044820152606490fd5b3461026757600036600319011261026757602060ff6000805160206126fd83398151915254166040519015158152f35b34610267576112a1366119ae565b91906112ab612002565b6001600160a01b038216928315611353576001546001600160a01b0316841461133e5783600052600260205260ff6040600020541661133e576113277ffd288a46d080f2a24ab4d47d4231a7ae3a4538d57a6c1c9afe6807e6c949f6ea938560005260026020526040600020600160ff19825416179055611ac7565b610348604051928392602084526020840191611b4e565b836303b6566d60e41b60005260045260246000fd5b83634726455360e11b60005260045260246000fd5b34610267576000366003190112610267577f000000000000000000000000e205f573ac35453c2fe0e2e28e8af201c45464f46001600160a01b031630036113c15760206040516000805160206126bd8339815191528152f35b63703e46dd60e11b60005260046000fd5b6040366003190112610267576113e6611900565b6024359067ffffffffffffffff821161026757366023830112156102675781600401359061141382611964565b91611421604051938461192c565b8083526020830193366024838301011161026757816000926024602093018737840101526001600160a01b037f000000000000000000000000e205f573ac35453c2fe0e2e28e8af201c45464f416308114908115611639575b506113c1573360009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff161561161f576040516352d1902d60e01b81526001600160a01b0382169390602081600481885afa600091816115eb575b506114fb5784634c9c8ce360e01b60005260045260246000fd5b806000805160206126bd8339815191528692036115d75750823b156115c3576000805160206126bd83398151915280546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a28251156115a8576000809161084a945190845af43d156115a0573d9161158383611964565b92611591604051948561192c565b83523d6000602085013e61265b565b60609161265b565b505050346115b257005b63b398979f60e01b60005260046000fd5b634c9c8ce360e01b60005260045260246000fd5b632a87526960e21b60005260045260246000fd5b9091506020813d602011611617575b816116076020938361192c565b81010312610267575190866114e1565b3d91506115fa565b63e2517d3f60e01b60005233600452600060245260446000fd5b6000805160206126bd833981519152546001600160a01b0316141590508461147a565b3461026757600036600319011261026757611675612002565b60ff600554166116d8576000805160206126fd8339815191525460ff81161561052d5760ff19166000805160206126fd833981519152557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b6303d3ebcd60e31b6000524260045260246000fd5b3461026757604036600319011261026757611706611916565b336001600160a01b038216036117225761084a906004356122c3565b63334bd91960e11b60005260046000fd5b3461026757602036600319011261026757602061174e611900565b6001546040516001600160a01b0392831691909216148152f35b346102675760403660031901126102675761084a600435611787611916565b9061179461084082611a75565b61221a565b34610267576020366003190112610267576001600160a01b036117ba611900565b166000526006602052602060018060a01b0360406000205416604051908152f35b346102675760203660031901126102675760206117f9600435611a75565b604051908152f35b3461026757600036600319011261026757602060ff600554166040519015158152f35b34610267576000366003190112610267576001546040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa80156107055760009061187a575b602090604051908152f35b506020813d6020116118a5575b816118946020938361192c565b81010312610267576020905161186f565b3d9150611887565b34610267576020366003190112610267576004359063ffffffff60e01b821680920361026757602091637965db0b60e01b81149081156118ef575b5015158152f35b6301ffc9a760e01b149050836118e8565b600435906001600160a01b038216820361026757565b602435906001600160a01b038216820361026757565b90601f8019910116810190811067ffffffffffffffff82111761194e57604052565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff811161194e57601f01601f191660200190565b9181601f840112156102675782359167ffffffffffffffff8311610267576020838186019501011161026757565b906040600319830112610267576004356001600160a01b038116810361026757916024359067ffffffffffffffff8211610267576119ee91600401611980565b9091565b91909160208152825180602083015260005b818110611a25575060409293506000838284010152601f8019910116010190565b8060208092870101516040828601015201611a04565b6060906003190112610267576004356001600160a01b038116810361026757906024356001600160a01b0381168103610267579060443590565b6000526000805160206126dd83398151915260205260016040600020015490565b600354811015611ab157600360005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b90600354916801000000000000000083101561194e5760018301600355600092600354811015611b3a5760039093527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90920180546001600160a01b0319166001600160a01b0390931692909217909155565b634e487b7160e01b84526032600452602484fd5b908060209392818452848401376000828201840152601f01601f1916010190565b519069ffffffffffffffffffff8216820361026757565b9190820391821161025157565b6001600160a01b031660008181526002602052604090205460ff1615611c25576000908152600660205260409020546001600160a01b03168015611c255760a060049160405192838092633fabe5a360e21b82525afa806000928392611c38575b50611c03575050600090600090565b6000821315611c2e57611c1a620151809142611b86565b11611c255790600190565b50600090600090565b5050600090600090565b9290915060a0833d60a011611c87575b81611c5560a0938361192c565b810103126106fa5750611c6782611b6f565b506020820151611c7e608060608501519401611b6f565b50919038611bf4565b3d9150611c48565b60009060033d11611c9c57565b905060046000803e60005160e01c90565b600060443d10611d14576040513d600319016004823e8051913d602484011167ffffffffffffffff841117611d1f578282019283519167ffffffffffffffff8311611d17573d84016003190185840160200111611d175750611d149291016020019061192c565b90565b949350505050565b92915050565b9260018060a01b0382169283600052600260205260ff60406000205416156107115780156107265760ff600554166116d857600154611d6d906001600160a01b0316846123e1565b60015460405163095ea7b360e01b81526001600160a01b039091166004820181905260248201839052959060208160448160008a5af19081611f1c575b50611dc857858563482b72c160e11b60005260045260245260446000fd5b909294847f481d5df0eabfe013ffde1dd3d7772e0c6048492cc6553578f6b4b42d330f37b36020604097959751878152a36001546040516311f9fbc960e21b81526001600160a01b03878116600483015260248201869052909160209183916044918391600091165af19081611eed575b50611ea75784611e47611c8f565b6308c379a014611e5d576040513d6000823e3d90fd5b611e65611cad565b80611e705750610705565b600154611ea392611e8a916001600160a01b0316906123e1565b6040516367b2add760e01b8152918291600483016119f2565b0390fd5b60408051938452600160208501529394506001600160a01b03169290917fbaef96a0f557c7f11d0e08ab509145e537c066a3e0e7d7dc139d22378f6b40b49190a3600190565b6020813d602011611f14575b81611f066020938361192c565b810103126102675751611e39565b3d9150611ef9565b611f3d9060203d602011611f42575b611f35818361192c565b8101906123c9565b611daa565b503d611f2b565b6001600160a01b03821660008181526002602052604090205491929160ff1615611fee5783156107265760ff600554166116d8576001546001600160a01b031603611fe45750604081611fc8847f51e1faf377d8e0f71a34b9ed5c587eaf8009919f820117fe196b30ebc39049e39460018060a01b036001541661259b565b8151938452600060208501526001600160a01b031692a2600190565b611d149291612487565b63ee84f40b60e01b60005260045260246000fd5b3360009081527fb16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431c602052604090205460ff161561203b57565b63e2517d3f60e01b6000523360045260008051602061273d83398151915260245260446000fd5b60008181526000805160206126dd8339815191526020908152604080832033845290915290205460ff16156120945750565b63e2517d3f60e01b6000523360045260245260446000fd5b6001600160a01b03811660009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff16612158576001600160a01b031660008181527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d60205260408120805460ff191660011790553391907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b50600090565b6001600160a01b03811660009081527fb16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431c602052604090205460ff16612158576001600160a01b031660008181527fb16e88c42fd4e48df2dd6a2eabd6bc9aec654ec170056b470819f8892cc6431c60205260408120805460ff1916600117905533919060008051602061273d833981519152907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b60008181526000805160206126dd833981519152602090815260408083206001600160a01b038616845290915290205460ff166122bc5760008181526000805160206126dd833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050600090565b60008181526000805160206126dd833981519152602090815260408083206001600160a01b038616845290915290205460ff16156122bc5760008181526000805160206126dd833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b600260008051602061271d833981519152541461238e57600260008051602061271d83398151915255565b633ee5aeb560e01b60005260046000fd5b60ff6000805160206126fd83398151915254166123b857565b63d93c066560e01b60005260046000fd5b90816020910312610267575180151581036102675790565b60405163095ea7b360e01b81526001600160a01b03928316600482018190526000602483018190529094929093169260209082906044908290875af1908161246a575b50612441575063482b72c160e11b60005260045260245260446000fd5b91907f97a94ee714dc2c5c1889f6fe8e8909a95e0307c4b272c7df374bf76582099f87600080a3565b6124829060203d602011611f4257611f35818361192c565b612424565b600154604051633def417960e11b815260048101949094526001600160a01b039283166024850152909160209184916044918391600091165af160009281612567575b5061251d576124d7611c8f565b6308c379a0146124ed576040513d6000823e3d90fd5b6124f5611cad565b806125005750610705565b604051636eb276e760e11b8152908190611ea390600483016119f2565b60015460408051938452600060208501526001600160a01b039283169391909216917fbaef96a0f557c7f11d0e08ab509145e537c066a3e0e7d7dc139d22378f6b40b491a3600190565b9092506020813d602011612593575b816125836020938361192c565b81010312610267575191386124ca565b3d9150612576565b60405163a9059cbb60e01b60208083019182526001600160a01b0394909416602483015260448083019590955293815290926000916125db60648261192c565b519082855af115610705576000513d61262457506001600160a01b0381163b155b6126035750565b635274afe760e01b60009081526001600160a01b0391909116600452602490fd5b600114156125fc565b60ff60008051602061275d8339815191525460401c161561264a57565b631afcd79f60e31b60005260046000fd5b90612681575080511561267057805190602001fd5b63d6bda27560e01b60005260046000fd5b815115806126b3575b612692575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561268a56fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800cd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a164736f6c634300081b000a

Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
Loading...
Loading

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