ETH Price: $1,904.69 (+0.00%)

Contract

0x5A007D6E37633FB297b82c074b94Bb29546BEbc3

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Multichain Info

No addresses found
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:
ERC20RebasableBridgedPermit

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 100000 runs

Other Settings:
default evmVersion
File 1 of 29 : ERC20RebasableBridgedPermit.sol
// SPDX-FileCopyrightText: 2024 OpenZeppelin, Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

import {ERC20RebasableBridged} from "./ERC20RebasableBridged.sol";
import {PermitExtension} from "./PermitExtension.sol";
import {Versioned} from "../utils/Versioned.sol";

/// @author kovalgek
/// @notice extends ERC20RebasableBridged functionality that allows to use permits and versioning.
contract ERC20RebasableBridgedPermit is ERC20RebasableBridged, PermitExtension, Versioned {

    /// @param name_ The name of the token
    /// @param symbol_ The symbol of the token
    /// @param version_ The current major version of the signing domain (aka token version)
    /// @param decimals_ The decimals places of the token
    /// @param tokenToWrapFrom_ address of the ERC20 token to wrap
    /// @param tokenRateOracle_ address of oracle that returns tokens rate
    /// @param bridge_ The bridge address which allowd to mint/burn tokens
    constructor(
        string memory name_,
        string memory symbol_,
        string memory version_,
        uint8 decimals_,
        address tokenToWrapFrom_,
        address tokenRateOracle_,
        address bridge_
    )
        ERC20RebasableBridged(
            name_,
            symbol_,
            decimals_,
            tokenToWrapFrom_,
            tokenRateOracle_,
            bridge_
        )
        PermitExtension(name_, version_)
    {
    }

    /// @notice Initializes the contract from scratch.
    /// @param name_ The name of the token
    /// @param symbol_ The symbol of the token
    /// @param version_ The version of the token
    function initialize(string memory name_, string memory symbol_, string memory version_) external {
        _initializeContractVersionTo(1);
        _initializeERC20Metadata(name_, symbol_);
        _initializeEIP5267Metadata(name_, version_);
    }

    /// @inheritdoc PermitExtension
    function _permitAccepted(address owner_, address spender_, uint256 amount_) internal override {
        _approve(owner_, spender_, amount_);
    }
}

File 2 of 29 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.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:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

    /**
     * @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 override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 3 of 29 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

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

File 4 of 29 : draft-IERC2612.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/draft-IERC2612.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/extensions/draft-IERC20Permit.sol";

interface IERC2612 is IERC20Permit {}

File 5 of 29 : IERC1271.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

import "./ECDSA.sol";

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

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

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

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

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

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

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

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

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

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

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

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

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

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

File 13 of 29 : SignatureChecker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";
import "../Address.sol";
import "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA
 * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like
 * Argent and Gnosis Safe.
 *
 * _Available since v4.1._
 */
library SignatureChecker {
    /**
     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidSignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
        if (error == ECDSA.RecoverError.NoError && recovered == signer) {
            return true;
        }

        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)
        );
        return (success && result.length == 32 && abi.decode(result, (bytes4)) == IERC1271.isValidSignature.selector);
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

File 15 of 29 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

File 16 of 29 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

File 18 of 29 : UnstructuredRefStorage.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

/// @dev A copy of UnstructuredRefStorage.sol library from Lido on Ethereum protocol.
///      https://github.com/lidofinance/lido-dao/blob/master/contracts/0.8.9/lib/UnstructuredRefStorage.sol
library UnstructuredRefStorage {
    function storageMapAddressMapAddressUint256(bytes32 _position) internal pure returns (
        mapping(address => mapping(address => uint256)) storage result
    ) {
        assembly { result.slot := _position }
    }

    function storageMapAddressAddressUint256(bytes32 _position) internal pure returns (
        mapping(address => uint256) storage result
    ) {
        assembly { result.slot := _position }
    }
}

File 19 of 29 : UnstructuredStorage.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

/// @dev A copy of UnstructuredStorage.sol library from Lido on Ethereum protocol.
///      https://github.com/lidofinance/lido-dao/blob/master/contracts/0.8.9/lib/UnstructuredStorage.sol
library UnstructuredStorage {
    function getStorageBool(bytes32 position) internal view returns (bool data) {
        assembly { data := sload(position) }
    }

    function getStorageUint256(bytes32 position) internal view returns (uint256 data) {
        assembly { data := sload(position) }
    }

    function setStorageBool(bytes32 position, bool data) internal {
        assembly { sstore(position, data) }
    }

    function setStorageUint256(bytes32 position, uint256 data) internal {
        assembly { sstore(position, data) }
    }
}

File 20 of 29 : CrossDomainEnabled.sol
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

import {ICrossDomainMessenger} from "./interfaces/ICrossDomainMessenger.sol";

/// @dev Helper contract for contracts performing cross-domain communications
contract CrossDomainEnabled {
    /// @notice Messenger contract used to send and receive messages from the other domain
    ICrossDomainMessenger public immutable MESSENGER;

    /// @param messenger_ Address of the CrossDomainMessenger on the current layer
    constructor(address messenger_) {
        if (messenger_ == address(0)) {
            revert ErrorZeroAddressMessenger();
        }
        MESSENGER = ICrossDomainMessenger(messenger_);
    }

    /// @dev Sends a message to an account on another domain
    /// @param crossDomainTarget_ Intended recipient on the destination domain
    /// @param message_ Data to send to the target (usually calldata to a function with
    ///     `onlyFromCrossDomainAccount()`)
    /// @param gasLimit_ gasLimit for the receipt of the message on the target domain.
    function sendCrossDomainMessage(
        address crossDomainTarget_,
        uint32 gasLimit_,
        bytes memory message_
    ) internal {
        MESSENGER.sendMessage(crossDomainTarget_, message_, gasLimit_);
    }

    /// @dev Enforces that the modified function is only callable by a specific cross-domain account
    /// @param sourceDomainAccount_ The only account on the originating domain which is
    ///     authenticated to call this function
    modifier onlyFromCrossDomainAccount(address sourceDomainAccount_) {
        if (msg.sender != address(MESSENGER)) {
            revert ErrorUnauthorizedMessenger();
        }
        if (MESSENGER.xDomainMessageSender() != sourceDomainAccount_) {
            revert ErrorWrongCrossDomainSender();
        }
        _;
    }

    error ErrorZeroAddressMessenger();
    error ErrorUnauthorizedMessenger();
    error ErrorWrongCrossDomainSender();
}

File 21 of 29 : IChainlinkAggregatorInterface.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

/// @author kovalgek
/// @notice A subset of chainlink data feed interface for token rate oracle.
interface IChainlinkAggregatorInterface {
    /// @notice get the latest token rate data.
    /// @return roundId_ is a unique id for each answer. The value is based on timestamp.
    /// @return answer_ is wstETH/stETH token rate. It is a chainlink convention to return int256.
    /// @return startedAt_ is time when rate was pushed on L1 side.
    /// @return updatedAt_ is the same as startedAt_.
    /// @return answeredInRound_ is the same as roundId_.
    function latestRoundData()
        external
        view
        returns (
            uint80 roundId_,
            int256 answer_,
            uint256 startedAt_,
            uint256 updatedAt_,
            uint80 answeredInRound_
        );

    /// @notice get the lastest token rate.
    /// @return wstETH/stETH token rate. It is a chainlink convention to return int256.
    function latestAnswer() external view returns (int256);

    /// @notice represents the number of decimals the oracle responses represent.
    /// @return decimals of the oracle response.
    function decimals() external view returns (uint8);
}

File 22 of 29 : ICrossDomainMessenger.sol
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

interface ICrossDomainMessenger {
    function xDomainMessageSender() external view returns (address);

    /// Sends a cross domain message to the target messenger.
    /// @param _target Target contract address.
    /// @param _message Message to send to the target.
    /// @param _gasLimit Gas limit for the provided message.
    function sendMessage(
        address _target,
        bytes calldata _message,
        uint32 _gasLimit
    ) external;
}

File 23 of 29 : ITokenRateUpdatable.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

/// @author kovalgek
/// @notice An interface for updating token rate of token rate oracle.
interface ITokenRateUpdatable {
    /// @notice Updates token rate.
    /// @param tokenRate_ wstETH/stETH token rate.
    /// @param rateUpdatedL1Timestamp_ L1 time when rate was updated on L1 side.
    function updateRate(uint256 tokenRate_, uint256 rateUpdatedL1Timestamp_) external;
}

File 24 of 29 : TokenRateOracle.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

import {ITokenRateUpdatable} from "./interfaces/ITokenRateUpdatable.sol";
import {IChainlinkAggregatorInterface} from "./interfaces/IChainlinkAggregatorInterface.sol";
import {CrossDomainEnabled} from "./CrossDomainEnabled.sol";
import {Versioned} from "../utils/Versioned.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {UnstructuredStorage} from "../lib/UnstructuredStorage.sol";

interface ITokenRateOracle is ITokenRateUpdatable, IChainlinkAggregatorInterface {}

/// @author kovalgek
/// @notice Oracle for storing and providing token rate.
///         NB: Cross-chain apps and CEXes should fetch the token rate specific to the chain for deposits/withdrawals
///         and compare against the token rate on L1 being an ultimate source of truth;
///         If the L1 rate differs, it can be pushed permissionlessly via OpStackTokenRatePusher.
/// @dev Token rate updates can be delivered from two sources: L1 token rate pusher and L2 bridge.
contract TokenRateOracle is ITokenRateOracle, CrossDomainEnabled, AccessControl, Versioned {

    using UnstructuredStorage for bytes32;

    /// @dev Used to store historical data of rate and times.
    struct TokenRateData {
        /// @notice wstETH/stETH token rate.
        uint128 tokenRate;
        /// @notice last time when token rate was updated on L1.
        uint64 rateUpdatedL1Timestamp;
        /// @notice last time when token rate was received on L2.
        uint64 rateReceivedL2Timestamp;
    } // occupies a single slot

    /// @notice A bridge which can update oracle.
    address public immutable L2_ERC20_TOKEN_BRIDGE;

    /// @notice An address of account on L1 that can update token rate.
    address public immutable L1_TOKEN_RATE_PUSHER;

    /// @notice A time period when token rate can be considered outdated.
    uint256 public immutable TOKEN_RATE_OUTDATED_DELAY;

    /// @notice A time difference between received l1Timestamp and L2 block.timestamp
    ///         when token rate can be considered outdated.
    uint256 public immutable MAX_ALLOWED_L2_TO_L1_CLOCK_LAG;

    /// @notice Allowed token rate deviation per day in basic points.
    uint256 public immutable MAX_ALLOWED_TOKEN_RATE_DEVIATION_PER_DAY_BP;

    /// @notice The maximum allowed time difference between the current time and the last received
    ///         token rate update that can be set during a pause. This is required to limit the pause role
    ///         and mitigate potential economic attacks.
    ///         See the 'pauseTokenRateUpdates()' method
    uint256 public immutable OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN;

    /// @notice The minimum delta time between two L1 timestamps of token rate updates.
    uint256 public immutable MIN_TIME_BETWEEN_TOKEN_RATE_UPDATES;

    /// @notice Decimals of the oracle response.
    uint8 public constant DECIMALS = 27;

    /// @notice Max sane token rate value.
    uint256 public constant MAX_SANE_TOKEN_RATE = 10 ** (DECIMALS + 2);

    /// @notice Min sane token rate value.
    uint256 public constant MIN_SANE_TOKEN_RATE = 10 ** (DECIMALS - 2);

    /// @dev Role granting the permission to pause updating rate.
    bytes32 public constant RATE_UPDATE_DISABLER_ROLE = keccak256("TokenRateOracle.RATE_UPDATE_DISABLER_ROLE");

    /// @dev Role granting the permission to resume updating rate.
    bytes32 public constant RATE_UPDATE_ENABLER_ROLE = keccak256("TokenRafteOracle.RATE_UPDATE_ENABLER_ROLE");

    /// @notice Basic point scale.
    uint256 private constant BASIS_POINT_SCALE = 1e4;

    /// @notice Number of seconds in one day.
    uint256 private constant ONE_DAY_SECONDS = 86400;

    /// @notice Flag to pause token rate updates slot position.
    bytes32 private constant PAUSE_TOKEN_RATE_UPDATES_SLOT = keccak256("TokenRateOracle.PAUSE_TOKEN_RATE_UPDATES_SLOT");

    /// @notice Token rates array slot position.
    bytes32 private constant TOKEN_RATES_DATA_SLOT = keccak256("TokenRateOracle.TOKEN_RATES_DATA_SLOT");

    /// @param messenger_ L2 messenger address being used for cross-chain communications
    /// @param l2ERC20TokenBridge_ the bridge address that has a right to updates oracle.
    /// @param l1TokenRatePusher_ An address of account on L1 that can update token rate.
    /// @param tokenRateOutdatedDelay_ time period when token rate can be considered outdated.
    /// @param maxAllowedL2ToL1ClockLag_ A time difference between received l1Timestamp and L2 block.timestamp
    ///         when token rate can be considered outdated.
    /// @param maxAllowedTokenRateDeviationPerDayBp_ Allowed token rate deviation per day in basic points.
    ///        Can't be bigger than BASIS_POINT_SCALE.
    /// @param oldestRateAllowedInPauseTimeSpan_ Maximum allowed time difference between the current time
    ///        and the last received token rate update that can be set during a pause.
    /// @param minTimeBetweenTokenRateUpdates_ Minimum delta time between two
    ///        L1 timestamps of token rate updates.
    constructor(
        address messenger_,
        address l2ERC20TokenBridge_,
        address l1TokenRatePusher_,
        uint256 tokenRateOutdatedDelay_,
        uint256 maxAllowedL2ToL1ClockLag_,
        uint256 maxAllowedTokenRateDeviationPerDayBp_,
        uint256 oldestRateAllowedInPauseTimeSpan_,
        uint256 minTimeBetweenTokenRateUpdates_
    ) CrossDomainEnabled(messenger_) {
        if (l2ERC20TokenBridge_ == address(0)) {
            revert ErrorZeroAddressL2ERC20TokenBridge();
        }
        if (l1TokenRatePusher_ == address(0)) {
            revert ErrorZeroAddressL1TokenRatePusher();
        }
        if (maxAllowedTokenRateDeviationPerDayBp_ == 0 || maxAllowedTokenRateDeviationPerDayBp_ > BASIS_POINT_SCALE) {
            revert ErrorMaxTokenRateDeviationIsOutOfRange();
        }
        L2_ERC20_TOKEN_BRIDGE = l2ERC20TokenBridge_;
        L1_TOKEN_RATE_PUSHER = l1TokenRatePusher_;
        TOKEN_RATE_OUTDATED_DELAY = tokenRateOutdatedDelay_;
        MAX_ALLOWED_L2_TO_L1_CLOCK_LAG = maxAllowedL2ToL1ClockLag_;
        MAX_ALLOWED_TOKEN_RATE_DEVIATION_PER_DAY_BP = maxAllowedTokenRateDeviationPerDayBp_;
        OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN = oldestRateAllowedInPauseTimeSpan_;
        MIN_TIME_BETWEEN_TOKEN_RATE_UPDATES = minTimeBetweenTokenRateUpdates_;
    }

    /// @notice Initializes the contract from scratch.
    /// @param admin_ Address of the account to grant the DEFAULT_ADMIN_ROLE
    /// @param tokenRate_ wstETH/stETH token rate, uses 10**DECIMALS precision.
    /// @param rateUpdatedL1Timestamp_ L1 time when rate was updated on L1 side.
    function initialize(address admin_, uint256 tokenRate_, uint256 rateUpdatedL1Timestamp_) external {
        _initializeContractVersionTo(1);
        if (admin_ == address(0)) {
            revert ErrorZeroAddressAdmin();
        }
        if (tokenRate_ < MIN_SANE_TOKEN_RATE || tokenRate_ > MAX_SANE_TOKEN_RATE) {
            revert ErrorTokenRateIsOutOfSaneRange(tokenRate_);
        }
        if (rateUpdatedL1Timestamp_ > block.timestamp + MAX_ALLOWED_L2_TO_L1_CLOCK_LAG) {
            revert ErrorL1TimestampExceededMaxAllowedClockLag(rateUpdatedL1Timestamp_);
        }
        _grantRole(DEFAULT_ADMIN_ROLE, admin_);
        _addTokenRate(tokenRate_, rateUpdatedL1Timestamp_, block.timestamp);
    }

    /// @notice Pauses token rate updates and sets the old rate provided by tokenRateIndex_.
    ///         Should be called by DAO or emergency brakes only.
    /// @param tokenRateIndex_ The index of the token rate that applies after the pause.
    ///        Token Rate can't be received older then OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN
    ///        except only if the passed index is the latest one.
    function pauseTokenRateUpdates(uint256 tokenRateIndex_) external onlyRole(RATE_UPDATE_DISABLER_ROLE) {
        if (_isPaused()) {
            revert ErrorAlreadyPaused();
        }
        TokenRateData memory tokenRateData = _getTokenRateByIndex(tokenRateIndex_);
        if (tokenRateIndex_ != _getStorageTokenRates().length - 1 &&
            tokenRateData.rateReceivedL2Timestamp < block.timestamp - OLDEST_RATE_ALLOWED_IN_PAUSE_TIME_SPAN) {
            revert ErrorTokenRateUpdateTooOld();
        }
        _removeElementsAfterIndex(tokenRateIndex_);
        _setPause(true);
        emit TokenRateUpdatesPaused(tokenRateData.tokenRate, tokenRateData.rateUpdatedL1Timestamp);
        emit RateUpdated(tokenRateData.tokenRate, tokenRateData.rateUpdatedL1Timestamp);
    }

    /// @notice Resume token rate updates applying provided token rate.
    /// @param tokenRate_ a new token rate that applies after resuming.
    /// @param rateUpdatedL1Timestamp_ L1 time when rate was updated on L1 side.
    function resumeTokenRateUpdates(
        uint256 tokenRate_,
        uint256 rateUpdatedL1Timestamp_
    ) external onlyRole(RATE_UPDATE_ENABLER_ROLE) {
        if (!_isPaused()) {
            revert ErrorAlreadyResumed();
        }
        if (tokenRate_ < MIN_SANE_TOKEN_RATE || tokenRate_ > MAX_SANE_TOKEN_RATE) {
            revert ErrorTokenRateIsOutOfSaneRange(tokenRate_);
        }
        if (rateUpdatedL1Timestamp_ > block.timestamp + MAX_ALLOWED_L2_TO_L1_CLOCK_LAG) {
            revert ErrorL1TimestampExceededMaxAllowedClockLag(rateUpdatedL1Timestamp_);
        }
        if (rateUpdatedL1Timestamp_ < _getLastTokenRate().rateUpdatedL1Timestamp) {
            revert ErrorL1TimestampOlderThanPrevious(rateUpdatedL1Timestamp_);
        }
        _addTokenRate(tokenRate_, rateUpdatedL1Timestamp_, block.timestamp);
        _setPause(false);
        emit TokenRateUpdatesResumed(tokenRate_, rateUpdatedL1Timestamp_);
        emit RateUpdated(tokenRate_, rateUpdatedL1Timestamp_);
    }

    /// @notice Shows that token rate updates are paused or not.
    function isTokenRateUpdatesPaused() external view returns (bool) {
        return _isPaused();
    }

    /// @notice Returns token rate data by index.
    /// @param tokenRateIndex_ an index of token rate data.
    function getTokenRateByIndex(uint256 tokenRateIndex_) external view returns (TokenRateData memory) {
        return _getTokenRateByIndex(tokenRateIndex_);
    }

    /// @notice Returns token rates data length.
    function getTokenRatesLength() external view returns (uint256) {
        return _getStorageTokenRates().length;
    }

    /// @inheritdoc IChainlinkAggregatorInterface
    function latestRoundData() external view returns (
        uint80 roundId_,
        int256 answer_,
        uint256 startedAt_,
        uint256 updatedAt_,
        uint80 answeredInRound_
    ) {
        TokenRateData memory tokenRateData = _getLastTokenRate();
        return (
            uint80(tokenRateData.rateUpdatedL1Timestamp),
            int256(uint256(tokenRateData.tokenRate)),
            tokenRateData.rateUpdatedL1Timestamp,
            tokenRateData.rateReceivedL2Timestamp,
            uint80(tokenRateData.rateUpdatedL1Timestamp)
        );
    }

    /// @inheritdoc IChainlinkAggregatorInterface
    function latestAnswer() external view returns (int256) {
        TokenRateData memory tokenRateData = _getLastTokenRate();
        return int256(uint256(tokenRateData.tokenRate));
    }

    /// @inheritdoc IChainlinkAggregatorInterface
    function decimals() external pure returns (uint8) {
        return DECIMALS;
    }

    /// @inheritdoc ITokenRateUpdatable
    function updateRate(
        uint256 tokenRate_,
        uint256 rateUpdatedL1Timestamp_
    ) external onlyBridgeOrTokenRatePusher {
        if (_isPaused()) {
            emit TokenRateUpdateAttemptDuringPause();
            return;
        }

        TokenRateData storage tokenRateData = _getLastTokenRate();

        /// @dev checks if the clock lag (i.e, time difference) between L1 and L2 exceeds the configurable threshold
        if (rateUpdatedL1Timestamp_ > block.timestamp + MAX_ALLOWED_L2_TO_L1_CLOCK_LAG) {
            revert ErrorL1TimestampExceededAllowedClockLag(tokenRate_, rateUpdatedL1Timestamp_);
        }

        /// @dev Use only the most up-to-date token rate. Reverting should be avoided as it may occur occasionally.
        if (rateUpdatedL1Timestamp_ < tokenRateData.rateUpdatedL1Timestamp) {
            emit DormantTokenRateUpdateIgnored(rateUpdatedL1Timestamp_, tokenRateData.rateUpdatedL1Timestamp);
            return;
        }

        /// @dev Bump L2 receipt time, don't touch the rate othwerwise
        /// NB: Here we assume that the rate can only be changed together with the token rebase induced
        /// by the AccountingOracle report
        if (rateUpdatedL1Timestamp_ == tokenRateData.rateUpdatedL1Timestamp) {
            tokenRateData.rateReceivedL2Timestamp = uint64(block.timestamp);
            emit RateReceivedTimestampUpdated(block.timestamp);
            return;
        }

        /// @dev This condition was made under the assumption that the L1 timestamps can be manipulated.
        if (rateUpdatedL1Timestamp_ < tokenRateData.rateUpdatedL1Timestamp + MIN_TIME_BETWEEN_TOKEN_RATE_UPDATES) {
            emit UpdateRateIsTooOften(rateUpdatedL1Timestamp_, tokenRateData.rateUpdatedL1Timestamp);
            return;
        }

        /// @dev allow token rate to be within some configurable range that depens on time it wasn't updated.
        if (!_isTokenRateWithinAllowedRange(
            tokenRateData.tokenRate,
            tokenRate_,
            tokenRateData.rateUpdatedL1Timestamp,
            rateUpdatedL1Timestamp_)
        ) {
            revert ErrorTokenRateIsOutOfRange(tokenRate_, rateUpdatedL1Timestamp_);
        }

        /// @dev notify that there is a differnce L1 and L2 time.
        if (rateUpdatedL1Timestamp_ > block.timestamp) {
            emit TokenRateL1TimestampIsInFuture(tokenRate_, rateUpdatedL1Timestamp_);
        }

        _addTokenRate(tokenRate_, rateUpdatedL1Timestamp_, block.timestamp);
        emit RateUpdated(tokenRate_, rateUpdatedL1Timestamp_);
    }

    /// @notice Returns flag that shows that token rate can be considered outdated.
    function isLikelyOutdated() external view returns (bool) {
        return (block.timestamp > _getLastTokenRate().rateReceivedL2Timestamp + TOKEN_RATE_OUTDATED_DELAY) ||
            _isPaused();
    }

    /// @notice Allow tokenRate deviation from the previous value to be
    ///         ±`MAX_ALLOWED_TOKEN_RATE_DEVIATION_PER_DAY` BP per day.
    function _isTokenRateWithinAllowedRange(
        uint256 currentTokenRate_,
        uint256 newTokenRate_,
        uint256 currentRateL1Timestamp_,
        uint256 newRateL1Timestamp_
    ) internal view returns (bool) {
        uint256 allowedTokenRateDeviation = _allowedTokenRateDeviation(newRateL1Timestamp_, currentRateL1Timestamp_);
        return newTokenRate_ <= _maxTokenRateLimit(currentTokenRate_, allowedTokenRateDeviation) &&
               newTokenRate_ >= _minTokenRateLimit(currentTokenRate_, allowedTokenRateDeviation);
    }

    /// @dev Returns the allowed token deviation depending on the number of days passed since the last update.
    function _allowedTokenRateDeviation(
        uint256 newRateL1Timestamp_,
        uint256 currentRateL1Timestamp_
    ) internal view returns (uint256) {
        uint256 rateL1TimestampDiff = newRateL1Timestamp_ - currentRateL1Timestamp_;
        uint256 roundedUpNumberOfDays = (rateL1TimestampDiff + ONE_DAY_SECONDS - 1) / ONE_DAY_SECONDS;
        return roundedUpNumberOfDays * MAX_ALLOWED_TOKEN_RATE_DEVIATION_PER_DAY_BP;
    }

    /// @dev Returns the maximum allowable value for the token rate.
    function _maxTokenRateLimit(
        uint256 currentTokenRate,
        uint256 allowedTokenRateDeviation
    ) internal pure returns (uint256) {
        uint256 maxTokenRateLimit = currentTokenRate * (BASIS_POINT_SCALE + allowedTokenRateDeviation) /
            BASIS_POINT_SCALE;
        return Math.min(maxTokenRateLimit, MAX_SANE_TOKEN_RATE);
    }

    /// @dev Returns the minimum allowable value for the token rate.
    function _minTokenRateLimit(
        uint256 currentTokenRate,
        uint256 allowedTokenRateDeviation
    ) internal pure returns (uint256) {
        uint256 minTokenRateLimit = MIN_SANE_TOKEN_RATE;
        if (allowedTokenRateDeviation <= BASIS_POINT_SCALE) {
            minTokenRateLimit = (currentTokenRate * (BASIS_POINT_SCALE - allowedTokenRateDeviation) /
            BASIS_POINT_SCALE);
        }
        return Math.max(minTokenRateLimit, MIN_SANE_TOKEN_RATE);
    }

    function _isCallerBridgeOrMessengerWithTokenRatePusher(address caller_) internal view returns (bool) {
        if (caller_ == L2_ERC20_TOKEN_BRIDGE) {
            return true;
        }
        if (caller_ == address(MESSENGER) && MESSENGER.xDomainMessageSender() == L1_TOKEN_RATE_PUSHER) {
            return true;
        }
        return false;
    }

    function _addTokenRate(
        uint256 tokenRate_, uint256 rateUpdatedL1Timestamp_, uint256 rateReceivedL2Timestamp_
    ) internal {
        _getStorageTokenRates().push(TokenRateData({
            tokenRate: uint128(tokenRate_),
            rateUpdatedL1Timestamp: uint64(rateUpdatedL1Timestamp_),
            rateReceivedL2Timestamp: uint64(rateReceivedL2Timestamp_)
        }));
    }

    function _getLastTokenRate() internal view returns (TokenRateData storage) {
        return _getTokenRateByIndex(_getStorageTokenRates().length - 1);
    }

    function _getTokenRateByIndex(uint256 tokenRateIndex_) internal view returns (TokenRateData storage) {
        if (tokenRateIndex_ >= _getStorageTokenRates().length) {
            revert ErrorWrongTokenRateIndex();
        }
        return _getStorageTokenRates()[tokenRateIndex_];
    }

    function _getStorageTokenRates() internal pure returns (TokenRateData [] storage result) {
        bytes32 position = TOKEN_RATES_DATA_SLOT;
        assembly {
            result.slot := position
        }
    }

    /// @dev tokenRateIndex_ is limited by time in the past and the number of elements also has restrictions.
    /// Therefore, this loop can't consume a lot of gas.
    function _removeElementsAfterIndex(uint256 tokenRateIndex_) internal {
        uint256 tokenRatesLength = _getStorageTokenRates().length;
        if (tokenRateIndex_ >= tokenRatesLength) {
            return;
        }
        uint256 numberOfElementsToRemove = tokenRatesLength - tokenRateIndex_ - 1;
        for (uint256 i = 0; i < numberOfElementsToRemove; i++) {
            _getStorageTokenRates().pop();
        }
    }

    function _setPause(bool pause) internal {
        PAUSE_TOKEN_RATE_UPDATES_SLOT.setStorageBool(pause);
    }

    function _isPaused() internal view returns (bool) {
        return PAUSE_TOKEN_RATE_UPDATES_SLOT.getStorageBool();
    }

    modifier onlyBridgeOrTokenRatePusher() {
        if (!_isCallerBridgeOrMessengerWithTokenRatePusher(msg.sender)) {
            revert ErrorNotBridgeOrTokenRatePusher();
        }
        _;
    }

    event RateUpdated(uint256 tokenRate_, uint256 indexed rateL1Timestamp_);
    event RateReceivedTimestampUpdated(uint256 indexed rateReceivedL2Timestamp);
    event DormantTokenRateUpdateIgnored(uint256 indexed newRateL1Timestamp_, uint256 indexed currentRateL1Timestamp_);
    event TokenRateL1TimestampIsInFuture(uint256 tokenRate_, uint256 indexed rateL1Timestamp_);
    event TokenRateUpdatesPaused(uint256 tokenRate_, uint256 indexed rateL1Timestamp_);
    event TokenRateUpdatesResumed(uint256 tokenRate_, uint256 indexed rateL1Timestamp_);
    event TokenRateUpdateAttemptDuringPause();
    event UpdateRateIsTooOften(uint256 indexed newRateL1Timestamp_, uint256 indexed currentRateL1Timestamp_);

    error ErrorZeroAddressAdmin();
    error ErrorWrongTokenRateIndex();
    error ErrorTokenRateUpdateTooOld();
    error ErrorAlreadyPaused();
    error ErrorAlreadyResumed();
    error ErrorZeroAddressL2ERC20TokenBridge();
    error ErrorZeroAddressL1TokenRatePusher();
    error ErrorNotBridgeOrTokenRatePusher();
    error ErrorL1TimestampExceededAllowedClockLag(uint256 tokenRate_, uint256 rateL1Timestamp_);
    error ErrorTokenRateIsOutOfRange(uint256 tokenRate_, uint256 rateL1Timestamp_);
    error ErrorMaxTokenRateDeviationIsOutOfRange();
    error ErrorTokenRateIsOutOfSaneRange(uint256 tokenRate_);
    error ErrorL1TimestampExceededMaxAllowedClockLag(uint256 rateL1Timestamp_);
    error ErrorL1TimestampOlderThanPrevious(uint256 rateL1Timestamp_);
}

File 25 of 29 : ERC20Metadata.sol
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

/// @author psirex
/// @notice Interface for the optional metadata functions from the ERC20 standard.
interface IERC20Metadata {
    /// @dev Returns the name of the token.
    function name() external view returns (string memory);

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

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

/// @author psirex
/// @notice Contains the optional metadata functions from the ERC20 standard
/// @dev Uses the UnstructuredStorage pattern to store dynamic name and symbol data. Might be used
///     with the upgradable proxies
contract ERC20Metadata is IERC20Metadata {
    /// @dev Stores the dynamic metadata of the ERC20 token. Allows safely use of this
    ///     contract with upgradable proxies
    struct DynamicMetadata {
        string name;
        string symbol;
    }

    /// @dev Location of the slot with DynamicMetdata
    ///      The slot's index string has a misspelling, but the contract storage will be broken without it.
    bytes32 private constant DYNAMIC_METADATA_SLOT =
        keccak256("ERC20Metdata.dynamicMetadata");

    /// @inheritdoc IERC20Metadata
    uint8 public immutable decimals;

    /// @param name_ Name of the token
    /// @param symbol_ Symbol of the token
    /// @param decimals_ Decimals places of the token
    constructor(
        string memory name_,
        string memory symbol_,
        uint8 decimals_
    ) {
        if (decimals_ == 0) {
            revert ErrorZeroDecimals();
        }
        decimals = decimals_;
        _setERC20MetadataName(name_);
        _setERC20MetadataSymbol(symbol_);
    }

    /// @inheritdoc IERC20Metadata
    function name() public view returns (string memory) {
        return _loadDynamicMetadata().name;
    }

    /// @inheritdoc IERC20Metadata
    function symbol() public view returns (string memory) {
        return _loadDynamicMetadata().symbol;
    }

    /// @dev Sets the name of the token.
    function _setERC20MetadataName(string memory name_) internal {
        if (bytes(name_).length == 0) {
            revert ErrorNameIsEmpty();
        }
        _loadDynamicMetadata().name = name_;
    }

    /// @dev Sets the symbol of the token.
    function _setERC20MetadataSymbol(string memory symbol_) internal {
        if (bytes(symbol_).length == 0) {
            revert ErrorSymbolIsEmpty();
        }
        _loadDynamicMetadata().symbol = symbol_;
    }

    function _isMetadataInitialized() internal view returns (bool) {
        return bytes(name()).length != 0 && bytes(symbol()).length != 0;
    }

    /// @dev Returns the reference to the slot with DynamicMetadata struct
    function _loadDynamicMetadata()
        private
        pure
        returns (DynamicMetadata storage r)
    {
        bytes32 slot = DYNAMIC_METADATA_SLOT;
        assembly {
            r.slot := slot
        }
    }

    error ErrorZeroDecimals();
    error ErrorNameIsEmpty();
    error ErrorSymbolIsEmpty();
}

File 26 of 29 : ERC20RebasableBridged.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20Wrapper} from "./interfaces/IERC20Wrapper.sol";
import {ITokenRateOracle} from "../optimism/TokenRateOracle.sol";
import {ERC20Metadata} from "./ERC20Metadata.sol";
import {UnstructuredRefStorage} from "../lib/UnstructuredRefStorage.sol";
import {UnstructuredStorage} from "../lib/UnstructuredStorage.sol";

/// @author kovalgek
/// @notice Extends the ERC20 functionality that allows the bridge to wrap/unwrap token.
interface IBridgeWrapper {
    /// @notice Returns bridge which can wrap/unwrap token on L2.
    function L2_ERC20_TOKEN_BRIDGE() external view returns (address);

    /// @notice Exchanges non-rebasable token (shares) to rebasable token. Can be called by bridge only.
    /// @param account_ an address of the account to exchange shares for.
    /// @param sharesAmount_ amount of non-rebasable token (shares).
    /// @return Amount of rebasable token.
    function bridgeWrap(address account_, uint256 sharesAmount_) external returns (uint256);

    /// @notice Exchanges rebasable token to non-rebasable (shares). Can be called by bridge only.
    /// @param account_ an address of the account to exchange token for.
    /// @param tokenAmount_ amount of rebasable token to uwrap in exchange for non-rebasable token (shares).
    /// @return Amount of non-rebasable token (shares) user receives after unwrap.
    function bridgeUnwrap(address account_, uint256 tokenAmount_) external returns (uint256);
}

/// @author kovalgek
/// @notice Rebasable token that wraps/unwraps non-rebasable token and allow to mint/burn tokens by bridge.
contract ERC20RebasableBridged is IERC20, IERC20Wrapper, IBridgeWrapper, ERC20Metadata {
    using SafeERC20 for IERC20;
    using UnstructuredRefStorage for bytes32;
    using UnstructuredStorage for bytes32;

    /// @inheritdoc IBridgeWrapper
    address public immutable L2_ERC20_TOKEN_BRIDGE;

    /// @notice Contract of non-rebasable token to wrap from.
    IERC20 public immutable TOKEN_TO_WRAP_FROM;

    /// @notice Oracle contract used to get token rate for wrapping/unwrapping tokens.
    ITokenRateOracle public immutable TOKEN_RATE_ORACLE;

    /// @notice Decimals of the oracle response.
    uint8 public immutable TOKEN_RATE_ORACLE_DECIMALS;

    /// @dev token allowance slot position.
    bytes32 internal constant TOKEN_ALLOWANCE_POSITION = keccak256("ERC20RebasableBridged.TOKEN_ALLOWANCE_POSITION");

    /// @dev user shares slot position.
    bytes32 internal constant SHARES_POSITION = keccak256("ERC20RebasableBridged.SHARES_POSITION");

    /// @dev token shares slot position.
    bytes32 internal constant TOTAL_SHARES_POSITION = keccak256("ERC20RebasableBridged.TOTAL_SHARES_POSITION");

    /// @param name_ The name of the token
    /// @param symbol_ The symbol of the token
    /// @param decimals_ The decimals places of the token
    /// @param tokenToWrapFrom_ address of the ERC20 token to wrap
    /// @param tokenRateOracle_ address of oracle that returns tokens rate
    /// @param l2ERC20TokenBridge_ The bridge address which allows to mint/burn tokens
    constructor(
        string memory name_,
        string memory symbol_,
        uint8 decimals_,
        address tokenToWrapFrom_,
        address tokenRateOracle_,
        address l2ERC20TokenBridge_
    ) ERC20Metadata(name_, symbol_, decimals_) {
        if (tokenToWrapFrom_ == address(0)) {
            revert ErrorZeroAddressTokenToWrapFrom();
        }
        if (tokenRateOracle_ == address(0)) {
            revert ErrorZeroAddressTokenRateOracle();
        }
        if (l2ERC20TokenBridge_ == address(0)) {
            revert ErrorZeroAddressL2ERC20TokenBridge();
        }
        TOKEN_TO_WRAP_FROM = IERC20(tokenToWrapFrom_);
        TOKEN_RATE_ORACLE = ITokenRateOracle(tokenRateOracle_);
        TOKEN_RATE_ORACLE_DECIMALS = TOKEN_RATE_ORACLE.decimals();
        L2_ERC20_TOKEN_BRIDGE = l2ERC20TokenBridge_;
    }

    /// @inheritdoc IERC20Wrapper
    function wrap(uint256 sharesAmount_) external returns (uint256) {
        return _wrap(msg.sender, msg.sender, sharesAmount_);
    }

    /// @inheritdoc IERC20Wrapper
    function unwrap(uint256 tokenAmount_) external returns (uint256) {
        return _unwrap(msg.sender, tokenAmount_);
    }

    /// @notice Exchanges rebasable token to non-rebasable by providing rebasable token shares.
    /// @param sharesAmount_ amount of rebasable token shares to unwrap.
    /// @return amount of non-rebasable token user receives after unwrap.
    function unwrapShares(uint256 sharesAmount_) external returns (uint256) {
        uint256 tokenAmount = _getTokensByShares(sharesAmount_);
        return _unwrapShares(msg.sender, sharesAmount_, tokenAmount);
    }

    /// @inheritdoc IBridgeWrapper
    function bridgeWrap(address account_, uint256 sharesAmount_) external onlyBridge returns (uint256) {
        return _wrap(L2_ERC20_TOKEN_BRIDGE, account_, sharesAmount_);
    }

    /// @inheritdoc IBridgeWrapper
    function bridgeUnwrap(address account_, uint256 tokenAmount_) external onlyBridge returns (uint256) {
        return _unwrap(account_, tokenAmount_);
    }

    /// @inheritdoc IERC20
    function allowance(address owner, address spender) external view returns (uint256) {
        return _getTokenAllowance()[owner][spender];
    }

    /// @inheritdoc IERC20
    function totalSupply() external view returns (uint256) {
        return _getTokensByShares(_getTotalShares());
    }

    /// @inheritdoc IERC20
    function balanceOf(address account_) external view returns (uint256) {
        return _getTokensByShares(_sharesOf(account_));
    }

    /// @notice Get shares amount of the provided account.
    /// @param account_ provided account address.
    /// @return amount of shares owned by `_account`.
    function sharesOf(address account_) external view returns (uint256) {
        return _sharesOf(account_);
    }

    /// @return total amount of shares.
    function getTotalShares() external view returns (uint256) {
        return _getTotalShares();
    }

    /// @notice Get amount of tokens for a given amount of shares.
    /// @param sharesAmount_ amount of shares.
    /// @return amount of tokens for a given shares amount.
    function getTokensByShares(uint256 sharesAmount_) external view returns (uint256) {
        return _getTokensByShares(sharesAmount_);
    }

    /// @notice Get amount of shares for a given amount of tokens.
    /// @param tokenAmount_ provided tokens amount.
    /// @return amount of shares for a given tokens amount.
    function getSharesByTokens(uint256 tokenAmount_) external view returns (uint256) {
        return _getSharesByTokens(tokenAmount_);
    }

    /// @inheritdoc IERC20
    function approve(address spender_, uint256 amount_) external returns (bool) {
        _approve(msg.sender, spender_, amount_);
        return true;
    }

    /// @inheritdoc IERC20
    function transfer(address to_, uint256 amount_) external returns (bool) {
        _transfer(msg.sender, to_, amount_);
        return true;
    }

    /// @inheritdoc IERC20
    function transferFrom(address from_, address to_, uint256 amount_) external returns (bool) {
        _spendAllowance(from_, msg.sender, amount_);
        _transfer(from_, to_, amount_);
        return true;
    }

    /// @notice Moves `sharesAmount_` token shares from the caller's account to the `recipient_` account.
    ///
    /// @return amount of transferred tokens.
    /// Emits a `TransferShares` event.
    /// Emits a `Transfer` event.
    ///
    /// Requirements:
    ///
    /// - `recipient_` cannot be the zero address.
    /// - the caller must have at least `sharesAmount_` shares.
    ///
    /// @dev The `sharesAmount_` argument is the amount of shares, not tokens.
    ///
    function transferShares(address recipient_, uint256 sharesAmount_) external returns (uint256) {
        _transferShares(msg.sender, recipient_, sharesAmount_);
        uint256 tokensAmount = _getTokensByShares(sharesAmount_);
        _emitTransferEvents(msg.sender, recipient_, tokensAmount, sharesAmount_);
        return tokensAmount;
    }

    /// @notice Moves `sharesAmount_` token shares from the `sender_` account to the `_recipient` account.
    ///
    /// @return amount of transferred tokens.
    /// Emits a `TransferShares` event.
    /// Emits a `Transfer` event.
    ///
    /// Requirements:
    ///
    /// - `sender_` and `_recipient` cannot be the zero addresses.
    /// - `sender_` must have at least `sharesAmount_` shares.
    /// - the caller must have allowance for `sender_`'s tokens of at least `_getTokensByShares(sharesAmount_)`.
    ///
    /// @dev The `_sharesAmount` argument is the amount of shares, not tokens.
    ///
    function transferSharesFrom(
        address sender_, address recipient_, uint256 sharesAmount_
    ) external returns (uint256) {
        uint256 tokensAmount = _getTokensByShares(sharesAmount_);
        _spendAllowance(sender_, msg.sender, tokensAmount);
        _transferShares(sender_, recipient_, sharesAmount_);
        _emitTransferEvents(sender_, recipient_, tokensAmount, sharesAmount_);
        return tokensAmount;
    }

    function _getTokenAllowance() internal pure returns (mapping(address => mapping(address => uint256)) storage) {
        return TOKEN_ALLOWANCE_POSITION.storageMapAddressMapAddressUint256();
    }

    /// @notice Amount of shares (locked wstETH amount) owned by the holder.
    function _getShares() internal pure returns (mapping(address => uint256) storage) {
        return SHARES_POSITION.storageMapAddressAddressUint256();
    }

    /// @notice The total amount of shares in existence.
    function _getTotalShares() internal view returns (uint256) {
        return TOTAL_SHARES_POSITION.getStorageUint256();
    }

    /// @notice Set total amount of shares.
    function _setTotalShares(uint256 _newTotalShares) internal {
        TOTAL_SHARES_POSITION.setStorageUint256(_newTotalShares);
    }

    /// @dev Moves amount_ of tokens from sender_ to recipient_
    /// @param from_ An address of the sender of the tokens
    /// @param to_  An address of the recipient of the tokens
    /// @param amount_ An amount of tokens to transfer
    function _transfer(
        address from_, address to_, uint256 amount_
    ) internal onlyNonZeroAccount(from_) onlyNonZeroAccount(to_) {
        uint256 sharesToTransfer = _getSharesByTokens(amount_);
        _transferShares(from_, to_, sharesToTransfer);
        _emitTransferEvents(from_, to_, amount_, sharesToTransfer);
    }

    /// @dev Updates owner_'s allowance for spender_ based on spent amount_. Does not update
    ///     the allowance amount in case of infinite allowance
    /// @param owner_ An address of the account to spend allowance
    /// @param spender_ An address of the spender of the tokens
    /// @param amount_ An amount of allowance spend
    function _spendAllowance(
        address owner_,
        address spender_,
        uint256 amount_
    ) internal {
        uint256 currentAllowance = _getTokenAllowance()[owner_][spender_];
        if (currentAllowance == type(uint256).max) {
            return;
        }
        if (amount_ > currentAllowance) {
            revert ErrorNotEnoughAllowance();
        }
        unchecked {
            _approve(owner_, spender_, currentAllowance - amount_);
        }
    }

    /// @dev Sets amount_ as the allowance of spender_ over the owner_'s tokens
    /// @param owner_ An address of the account to set allowance
    /// @param spender_ An address of the tokens spender
    /// @param amount_ An amount of tokens to allow to spend
    function _approve(
        address owner_,
        address spender_,
        uint256 amount_
    ) internal virtual onlyNonZeroAccount(owner_) onlyNonZeroAccount(spender_) {
        _getTokenAllowance()[owner_][spender_] = amount_;
        emit Approval(owner_, spender_, amount_);
    }

    function _sharesOf(address account_) internal view returns (uint256) {
        return _getShares()[account_];
    }

    function _getTokensByShares(uint256 sharesAmount_) internal view returns (uint256) {
        return (sharesAmount_ * _getTokenRate()) / (10 ** TOKEN_RATE_ORACLE_DECIMALS);
    }

    function _getSharesByTokens(uint256 tokenAmount_) internal view returns (uint256) {
        return (tokenAmount_ * (10 ** TOKEN_RATE_ORACLE_DECIMALS)) / _getTokenRate();
    }

    function _getTokenRate() internal view returns (uint256) {
        return uint256(TOKEN_RATE_ORACLE.latestAnswer());
    }

    /// @dev Creates `amount_` shares and assigns them to `account_`, increasing the total shares supply
    /// @param recipient_ An address of the account to mint shares
    /// @param amount_ An amount of shares to mint
    function _mintShares(
        address recipient_,
        uint256 amount_
    ) internal onlyNonZeroAccount(recipient_) {
        _setTotalShares(_getTotalShares() + amount_);
        _getShares()[recipient_] = _getShares()[recipient_] + amount_;
    }

    /// @dev Destroys `amount_` shares from `account_`, reducing the total shares supply.
    /// @param account_ An address of the account to mint shares
    /// @param amount_ An amount of shares to mint
    function _burnShares(
        address account_,
        uint256 amount_
    ) internal onlyNonZeroAccount(account_) {
        uint256 accountShares = _getShares()[account_];
        if (accountShares < amount_) revert ErrorNotEnoughBalance();
        _setTotalShares(_getTotalShares() - amount_);
        _getShares()[account_] = accountShares - amount_;
    }

    /// @dev  Moves `sharesAmount_` shares from `sender_` to `recipient_`.
    /// @param sender_ An address of the account to take shares
    /// @param recipient_ An address of the account to transfer shares
    /// @param sharesAmount_ An amount of shares to transfer
    function _transferShares(
        address sender_,
        address recipient_,
        uint256 sharesAmount_
    ) internal onlyNonZeroAccount(sender_) onlyNonZeroAccount(recipient_) {
        if (recipient_ == address(this)) revert ErrorTransferToRebasableContract();

        uint256 currentSenderShares = _getShares()[sender_];
        if (sharesAmount_ > currentSenderShares) revert ErrorNotEnoughBalance();

        _getShares()[sender_] = currentSenderShares - sharesAmount_;
        _getShares()[recipient_] = _getShares()[recipient_] + sharesAmount_;
    }

    /// @dev Emits `Transfer` and `TransferShares` events
    function _emitTransferEvents(
        address _from,
        address _to,
        uint256 _tokenAmount,
        uint256 _sharesAmount
    ) internal {
        emit Transfer(_from, _to, _tokenAmount);
        emit TransferShares(_from, _to, _sharesAmount);
    }

    /// @notice Sets the name and the symbol of the tokens if they both are empty
    /// @param name_ The name of the token
    /// @param symbol_ The symbol of the token
    function _initializeERC20Metadata(string memory name_, string memory symbol_) internal {
        _setERC20MetadataName(name_);
        _setERC20MetadataSymbol(symbol_);
    }

    function _wrap(address from_, address to_, uint256 sharesAmount_) internal returns (uint256) {
        if (sharesAmount_ == 0) revert ErrorZeroSharesWrap();
        TOKEN_TO_WRAP_FROM.safeTransferFrom(from_, address(this), sharesAmount_);
        _mintShares(to_, sharesAmount_);
        uint256 tokensAmount = _getTokensByShares(sharesAmount_);
        _emitTransferEvents(address(0), to_, tokensAmount, sharesAmount_);
        return tokensAmount;
    }

    function _unwrap(address account_, uint256 tokenAmount_) internal returns (uint256) {
        if (tokenAmount_ == 0) revert ErrorZeroTokensUnwrap();
        uint256 sharesAmount = _getSharesByTokens(tokenAmount_);
        return _unwrapShares(account_, sharesAmount, tokenAmount_);
    }

    function _unwrapShares(address account_, uint256 sharesAmount_, uint256 tokenAmount_) internal returns (uint256) {
        if (sharesAmount_ == 0) revert ErrorZeroSharesUnwrap();
        _burnShares(account_, sharesAmount_);
        _emitTransferEvents(account_, address(0), tokenAmount_, sharesAmount_);
        TOKEN_TO_WRAP_FROM.safeTransfer(account_, sharesAmount_);
        return sharesAmount_;
    }

    /// @dev validates that account_ is not zero address
    modifier onlyNonZeroAccount(address account_) {
        if (account_ == address(0)) {
            revert ErrorAccountIsZeroAddress();
        }
        _;
    }

    /// @dev Validates that sender of the transaction is the bridge
    modifier onlyBridge() {
        if (msg.sender != L2_ERC20_TOKEN_BRIDGE) {
            revert ErrorNotBridge();
        }
        _;
    }

    /// @notice An executed shares transfer from `sender` to `recipient`.
    /// @dev emitted in pair with an ERC20-defined `Transfer` event.
    event TransferShares(
        address indexed from,
        address indexed to,
        uint256 sharesValue
    );

    error ErrorZeroAddressTokenToWrapFrom();
    error ErrorZeroAddressTokenRateOracle();
    error ErrorZeroAddressL2ERC20TokenBridge();
    error ErrorZeroSharesWrap();
    error ErrorZeroTokensUnwrap();
    error ErrorZeroSharesUnwrap();
    error ErrorTransferToRebasableContract();
    error ErrorNotEnoughBalance();
    error ErrorNotEnoughAllowance();
    error ErrorAccountIsZeroAddress();
    error ErrorNotBridge();
}

File 27 of 29 : IERC20Wrapper.sol
// SPDX-FileCopyrightText: 2024 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

/// @author kovalgek
/// @notice Extends the ERC20 functionality that allows to wrap/unwrap token.
interface IERC20Wrapper {

    /// @notice Exchanges wrappable token to wrapper one.
    /// @param wrappableTokenAmount_ amount of wrappable token to wrap.
    /// @return Amount of wrapper token user receives after wrap.
    function wrap(uint256 wrappableTokenAmount_) external returns (uint256);

    /// @notice Exchanges wrapper token to wrappable one.
    /// @param wrapperTokenAmount_ amount of wrapper token to uwrap in exchange for wrappable.
    /// @return Amount of wrappable token user receives after unwrap.
    function unwrap(uint256 wrapperTokenAmount_) external returns (uint256);
}

File 28 of 29 : PermitExtension.sol
// SPDX-FileCopyrightText: 2024 OpenZeppelin, Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

import {IERC2612} from "@openzeppelin/contracts/interfaces/draft-IERC2612.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {UnstructuredRefStorage} from "../lib//UnstructuredRefStorage.sol";

/// @author arwer13, kovalgek
abstract contract PermitExtension is IERC2612, EIP712 {
    using UnstructuredRefStorage for bytes32;

    /// @dev Stores the dynamic metadata of the PermitExtension. Allows safely use of this
    ///     contract with upgradable proxies
    struct EIP5267Metadata {
        string name;
        string version;
    }

    /// @dev user nonce slot position.
    bytes32 internal constant NONCE_BY_ADDRESS_POSITION = keccak256("PermitExtension.NONCE_BY_ADDRESS_POSITION");

    /// @dev Typehash constant for ERC-2612 (Permit)
    /// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")
    bytes32 internal constant PERMIT_TYPEHASH =
        0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

    /// @dev Location of the slot with EIP5267Metadata
    bytes32 private constant EIP5267_METADATA_SLOT = keccak256("PermitExtension.eip5267MetadataSlot");

    /// @param name_ The name of the token
    /// @param version_ The current major version of the signing domain (aka token version)
    constructor(string memory name_, string memory version_) EIP712(name_, version_) {
        _initializeEIP5267Metadata(name_, version_);
    }

    /// @notice Sets `value_` as the allowance of `spender_` over `owner_`'s tokens, given `owner_`'s signed approval.
    /// @param owner_  Token owner's address (Authorizer). Cannot be the zero address.
    /// @param spender_  An address of the tokens spender. Cannot be the zero address.
    /// @param value_ An amount of tokens to allow to spend.
    /// @param deadline_ The time at which the signature expires (unix time). Must be a timestamp in the future.
    /// @param v_, r_, s_ must be a valid `secp256k1` signature from `owner`
    ///                   over the EIP712-formatted function arguments.
    ///                   The signature must use ``owner``'s current nonce (see {nonces}).
    function permit(
        address owner_,
        address spender_,
        uint256 value_,
        uint256 deadline_,
        uint8 v_,
        bytes32 r_,
        bytes32 s_
    ) external {
        _permit(owner_, spender_, value_, deadline_, abi.encodePacked(r_, s_, v_));
    }

    /// @notice Sets `value_` as the allowance of `spender_` over `owner_`'s tokens, given `owner_`'s signed approval.
    /// @param owner_  Token owner's address (Authorizer). Cannot be the zero address.
    /// @param spender_  An address of the tokens spender. Cannot be the zero address.
    /// @param value_ An amount of tokens to allow to spend.
    /// @param deadline_ The time at which the signature expires (unix time). Must be a timestamp in the future.
    /// @param signature_ Unstructured bytes signature signed by an EOA wallet or a contract wallet.
    function permit(
        address owner_,
        address spender_,
        uint256 value_,
        uint256 deadline_,
        bytes calldata signature_
    ) external {
        _permit(owner_, spender_, value_, deadline_, signature_);
    }

    function _permit(
        address owner_,
        address spender_,
        uint256 value_,
        uint256 deadline_,
        bytes memory signature_
    ) internal {
        if (block.timestamp > deadline_) {
            revert ErrorDeadlineExpired();
        }

        bytes32 hash = _hashTypedDataV4(
            keccak256(
                abi.encode(PERMIT_TYPEHASH, owner_, spender_, value_, _useNonce(owner_), deadline_)
            )
        );

        if (!SignatureChecker.isValidSignatureNow(owner_, hash, signature_)) {
            revert ErrorInvalidSignature();
        }

        _permitAccepted(owner_, spender_, value_);
    }

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

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

    /// @dev EIP-5267. Returns the fields and values that describe the domain separator
    /// used by this contract for EIP-712 signature.
    function eip712Domain()
        external
        view
        virtual
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        return (
            hex"0f", // 01111
            _loadEIP5267Metadata().name,
            _loadEIP5267Metadata().version,
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }

    /// @notice Sets the name and the version of the tokens if they both are empty
    /// @param name_ The name of the token
    /// @param version_ The version of the token
    function _initializeEIP5267Metadata(string memory name_, string memory version_) internal {
        _setEIP5267MetadataName(name_);
        _setEIP5267MetadataVersion(version_);
    }

    /// @dev "Consume a nonce": return the current value and increment.
    function _useNonce(address _owner) internal returns (uint256 current) {
        current = _getNonceByAddress()[_owner];
        _getNonceByAddress()[_owner] = current + 1;
    }

    /// @notice Nonces for ERC-2612 (Permit)
    function _getNonceByAddress() internal pure returns (mapping(address => uint256) storage) {
        return NONCE_BY_ADDRESS_POSITION.storageMapAddressAddressUint256();
    }

    /// @dev Override this function in the inherited contract to invoke the approve() function of ERC20.
    function _permitAccepted(address owner_, address spender_, uint256 amount_) internal virtual;

    /// @dev Sets the name of the token. Might be called only when the name is empty
    function _setEIP5267MetadataName(string memory name_) internal {
        _loadEIP5267Metadata().name = name_;
    }

    /// @dev Sets the version of the token. Might be called only when the version is empty
    function _setEIP5267MetadataVersion(string memory version_) internal {
        _loadEIP5267Metadata().version = version_;
    }

    /// @dev Returns the reference to the slot with EIP5267Metadata struct
    function _loadEIP5267Metadata() private pure returns (EIP5267Metadata storage r) {
        bytes32 slot = EIP5267_METADATA_SLOT;
        assembly {
            r.slot := slot
        }
    }

    error ErrorInvalidSignature();
    error ErrorDeadlineExpired();
}

File 29 of 29 : Versioned.sol
// SPDX-FileCopyrightText: 2022 Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.10;

import {UnstructuredStorage} from "../lib/UnstructuredStorage.sol";

/// @dev A copy of Versioned.sol contract from Lido on Ethereum protocol
///      https://github.com/lidofinance/lido-dao/blob/master/contracts/0.8.9/utils/Versioned.sol
contract Versioned {
    using UnstructuredStorage for bytes32;

    event ContractVersionSet(uint256 version);

    error NonZeroContractVersionOnInit();
    error InvalidContractVersionIncrement();
    error UnexpectedContractVersion(uint256 expected, uint256 received);

    /// @dev Storage slot: uint256 version
    /// Version of the initialized contract storage.
    /// The version stored in CONTRACT_VERSION_POSITION equals to:
    /// - 0 right after the deployment, before an initializer is invoked (and only at that moment);
    /// - N after calling initialize(), where N is the initially deployed contract version;
    /// - N after upgrading contract by calling finalizeUpgrade_vN().
    bytes32 internal constant CONTRACT_VERSION_POSITION = keccak256("lido.Versioned.contractVersion");

    uint256 internal constant PETRIFIED_VERSION_MARK = type(uint256).max;

    constructor() {
        // lock version in the implementation's storage to prevent initialization
        CONTRACT_VERSION_POSITION.setStorageUint256(PETRIFIED_VERSION_MARK);
    }

    /// @notice Returns the current contract version.
    function getContractVersion() public view returns (uint256) {
        return CONTRACT_VERSION_POSITION.getStorageUint256();
    }

    function _checkContractVersion(uint256 version) internal view {
        uint256 expectedVersion = getContractVersion();
        if (version != expectedVersion) {
            revert UnexpectedContractVersion(expectedVersion, version);
        }
    }

    /// @dev Sets the contract version to N. Should be called from the initialize() function.
    function _initializeContractVersionTo(uint256 version) internal {
        if (getContractVersion() != 0) revert NonZeroContractVersionOnInit();
        _setContractVersion(version);
    }

    /// @dev Updates the contract version. Should be called from a finalizeUpgrade_vN() function.
    function _updateContractVersion(uint256 newVersion) internal {
        if (newVersion != getContractVersion() + 1) revert InvalidContractVersionIncrement();
        _setContractVersion(newVersion);
    }

    function _setContractVersion(uint256 version) private {
        CONTRACT_VERSION_POSITION.setStorageUint256(version);
        emit ContractVersionSet(version);
    }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"string","name":"version_","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"address","name":"tokenToWrapFrom_","type":"address"},{"internalType":"address","name":"tokenRateOracle_","type":"address"},{"internalType":"address","name":"bridge_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ErrorAccountIsZeroAddress","type":"error"},{"inputs":[],"name":"ErrorDeadlineExpired","type":"error"},{"inputs":[],"name":"ErrorInvalidSignature","type":"error"},{"inputs":[],"name":"ErrorNameIsEmpty","type":"error"},{"inputs":[],"name":"ErrorNotBridge","type":"error"},{"inputs":[],"name":"ErrorNotEnoughAllowance","type":"error"},{"inputs":[],"name":"ErrorNotEnoughBalance","type":"error"},{"inputs":[],"name":"ErrorSymbolIsEmpty","type":"error"},{"inputs":[],"name":"ErrorTransferToRebasableContract","type":"error"},{"inputs":[],"name":"ErrorZeroAddressL2ERC20TokenBridge","type":"error"},{"inputs":[],"name":"ErrorZeroAddressTokenRateOracle","type":"error"},{"inputs":[],"name":"ErrorZeroAddressTokenToWrapFrom","type":"error"},{"inputs":[],"name":"ErrorZeroDecimals","type":"error"},{"inputs":[],"name":"ErrorZeroSharesUnwrap","type":"error"},{"inputs":[],"name":"ErrorZeroSharesWrap","type":"error"},{"inputs":[],"name":"ErrorZeroTokensUnwrap","type":"error"},{"inputs":[],"name":"InvalidContractVersionIncrement","type":"error"},{"inputs":[],"name":"NonZeroContractVersionOnInit","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"received","type":"uint256"}],"name":"UnexpectedContractVersion","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"version","type":"uint256"}],"name":"ContractVersionSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"sharesValue","type":"uint256"}],"name":"TransferShares","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"L2_ERC20_TOKEN_BRIDGE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_RATE_ORACLE","outputs":[{"internalType":"contract ITokenRateOracle","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_RATE_ORACLE_DECIMALS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_TO_WRAP_FROM","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"tokenAmount_","type":"uint256"}],"name":"bridgeUnwrap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"sharesAmount_","type":"uint256"}],"name":"bridgeWrap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getContractVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount_","type":"uint256"}],"name":"getSharesByTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"sharesAmount_","type":"uint256"}],"name":"getTokensByShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"string","name":"version_","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"},{"internalType":"uint256","name":"deadline_","type":"uint256"},{"internalType":"bytes","name":"signature_","type":"bytes"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"value_","type":"uint256"},{"internalType":"uint256","name":"deadline_","type":"uint256"},{"internalType":"uint8","name":"v_","type":"uint8"},{"internalType":"bytes32","name":"r_","type":"bytes32"},{"internalType":"bytes32","name":"s_","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"sharesOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient_","type":"address"},{"internalType":"uint256","name":"sharesAmount_","type":"uint256"}],"name":"transferShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender_","type":"address"},{"internalType":"address","name":"recipient_","type":"address"},{"internalType":"uint256","name":"sharesAmount_","type":"uint256"}],"name":"transferSharesFrom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount_","type":"uint256"}],"name":"unwrap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sharesAmount_","type":"uint256"}],"name":"unwrapShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"sharesAmount_","type":"uint256"}],"name":"wrap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

6101e06040523480156200001257600080fd5b50604051620033b4380380620033b48339810160408190526200003591620004fc565b86858181818a8989898985858560ff81166200006457604051635b15e36d60e11b815260040160405180910390fd5b60ff8116608052620000768362000287565b6200008182620002ce565b5050506001600160a01b038316620000ac57604051630911dfa360e31b815260040160405180910390fd5b6001600160a01b038216620000d457604051632724c68360e11b815260040160405180910390fd5b6001600160a01b038116620000fc5760405163bac34ad960e01b815260040160405180910390fd5b6001600160a01b0380841660c052821660e08190526040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa1580156200014d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001739190620005d8565b60ff16610100526001600160a01b031660a090815287516020808a01919091208851898301206101808290526101a081905246610140819052604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81870181905281830186905260608201859052608082019390935230818801528151808203909701875260c001905284519490930193909320909750919550935091506200021c9050565b6101205230610160526101c052506200023c925084915083905062000318565b50506200027a6000197f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a66200033f60201b62000b541790919060201c565b505050505050506200063a565b8051620002a75760405163348120a360e01b815260040160405180910390fd5b80600080516020620033748339815191525b8151620002ca92602001906200035a565b5050565b8051620002ee5760405163a02a947f60e01b815260040160405180910390fd5b80600080516020620033748339815191525b6001019080519060200190620002ca9291906200035a565b620003238262000343565b620002ca81806000805160206200339483398151915262000300565b9055565b8060008051602062003394833981519152620002b9565b8280546200036890620005fd565b90600052602060002090601f0160209004810192826200038c5760008555620003d7565b82601f10620003a757805160ff1916838001178555620003d7565b82800160010185558215620003d7579182015b82811115620003d7578251825591602001919060010190620003ba565b50620003e5929150620003e9565b5090565b5b80821115620003e55760008155600101620003ea565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200042857600080fd5b81516001600160401b038082111562000445576200044562000400565b604051601f8301601f19908116603f0116810190828211818310171562000470576200047062000400565b816040528381526020925086838588010111156200048d57600080fd5b600091505b83821015620004b1578582018301518183018401529082019062000492565b83821115620004c35760008385830101525b9695505050505050565b805160ff81168114620004df57600080fd5b919050565b80516001600160a01b0381168114620004df57600080fd5b600080600080600080600060e0888a0312156200051857600080fd5b87516001600160401b03808211156200053057600080fd5b6200053e8b838c0162000416565b985060208a01519150808211156200055557600080fd5b620005638b838c0162000416565b975060408a01519150808211156200057a57600080fd5b50620005898a828b0162000416565b9550506200059a60608901620004cd565b9350620005aa60808901620004e4565b9250620005ba60a08901620004e4565b9150620005ca60c08901620004e4565b905092959891949750929550565b600060208284031215620005eb57600080fd5b620005f682620004cd565b9392505050565b600181811c908216806200061257607f821691505b602082108114156200063457634e487b7160e01b600052602260045260246000fd5b50919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c051612c7b620006f96000396000610fba0152600061100901526000610fe401526000610f3d01526000610f6701526000610f9101526000818161040b01528181610cb5015261141c0152600081816102ad015261162401526000818161043201528181610ed701526110c10152600081816103be0152818161063c015281816106980152610adb0152600061026c0152612c7b6000f3fe608060405234801561001057600080fd5b50600436106101e55760003560e01c80638aa104351161010f578063c5ed7176116100a2578063de0e9a3e11610071578063de0e9a3e146104d4578063e53d44df146104e7578063ea598cb0146104fa578063f5eb42dc1461050d57600080fd5b8063c5ed71761461042d578063d5002f2e14610454578063d505accf1461045c578063dd62ed3e1461046f57600080fd5b8063a14a3a24116100de578063a14a3a24146103b9578063a6487c53146103e0578063a9059cbb146103f3578063b48b89b81461040657600080fd5b80638aa10435146103815780638fcb4e5b1461038957806395d89b411461039c5780639fd5a6cf146103a457600080fd5b806345a8306f1161018757806370a082311161015657806370a082311461032d5780637749c54f146103405780637ecebe001461035357806384b0196e1461036657600080fd5b806345a8306f146102a85780635290a4fa146102f45780636b37193c146103075780636d7804591461031a57600080fd5b806323b872dd116101c357806323b872dd146102415780632ed2493114610254578063313ce567146102675780633644e515146102a057600080fd5b806306fdde03146101ea578063095ea7b31461020857806318160ddd1461022b575b600080fd5b6101f2610520565b6040516101ff91906124c8565b60405180910390f35b61021b610216366004612504565b6105d1565b60405190151581526020016101ff565b6102336105e8565b6040519081526020016101ff565b61021b61024f36600461252e565b6105ff565b610233610262366004612504565b610622565b61028e7f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016101ff565b6102336106be565b6102cf7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101ff565b61023361030236600461256a565b6106c8565b61023361031536600461256a565b6106d3565b61023361032836600461252e565b6106ec565b61023361033b366004612583565b610724565b61023361034e36600461256a565b610732565b610233610361366004612583565b61073d565b61036e61078d565b6040516101ff979695949392919061259e565b610233610940565b610233610397366004612504565b61096a565b6101f2610990565b6103b76103b236600461265d565b6109c1565b005b6102cf7f000000000000000000000000000000000000000000000000000000000000000081565b6103b76103ee3660046127dd565b610a0c565b61021b610401366004612504565b610a2f565b61028e7f000000000000000000000000000000000000000000000000000000000000000081565b6102cf7f000000000000000000000000000000000000000000000000000000000000000081565b610233610a3c565b6103b761046a366004612865565b610a46565b61023361047d3660046128d8565b73ffffffffffffffffffffffffffffffffffffffff91821660009081527feb877d33aaa0a9f80a1336db341e03580b8e117f72ae4da24f28b8d9f542cf246020908152604080832093909416825291909152205490565b6102336104e236600461256a565b610ab5565b6102336104f5366004612504565b610ac1565b61023361050836600461256a565b610b3c565b61023361051b366004612583565b610b49565b60607f3470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e805461054e9061290b565b80601f016020809104026020016040519081016040528092919081815260200182805461057a9061290b565b80156105c75780601f1061059c576101008083540402835291602001916105c7565b820191906000526020600020905b8154815290600101906020018083116105aa57829003601f168201915b5050505050905090565b60006105de338484610b58565b5060015b92915050565b60006105fa6105f5610c84565b610cae565b905090565b600061060c843384610cf7565b610617848484610dc4565b5060015b9392505050565b60003373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610693576040517fb5f1e21f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61061b7f00000000000000000000000000000000000000000000000000000000000000008484610e84565b60006105fa610f23565b60006105e282610cae565b6000806106df83610cae565b905061061b338483611057565b6000806106f883610cae565b9050610705853383610cf7565b6107108585856110f0565b61071c85858386611311565b949350505050565b60006105e26105f5836113e5565b60006105e28261140d565b60007fdaad28896b706a809236aec38dc84ce99b9d9cf68b8751e946a9258d6de2c8f15b73ffffffffffffffffffffffffffffffffffffffff909216600090815260209290925250604090205490565b6000606080828080837f056ad441bfb3f4908fe527102b709e6e33a099187a55402844d65a5cc26af2198060010146306000806040519080825280602002602001820160405280156107e9578160200160208202803683370190505b507f0f0000000000000000000000000000000000000000000000000000000000000095949392919085805461081d9061290b565b80601f01602080910402602001604051908101604052809291908181526020018280546108499061290b565b80156108965780601f1061086b57610100808354040283529160200191610896565b820191906000526020600020905b81548152906001019060200180831161087957829003601f168201915b505050505095508480546108a99061290b565b80601f01602080910402602001604051908101604052809291908181526020018280546108d59061290b565b80156109225780601f106108f757610100808354040283529160200191610922565b820191906000526020600020905b81548152906001019060200180831161090557829003601f168201915b50505050509450965096509650965096509650965090919293949596565b60006105fa7f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a65490565b60006109773384846110f0565b600061098283610cae565b905061061b33858386611311565b60607f3470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e600101805461054e9061290b565b610a048686868686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061144292505050565b505050505050565b610a16600161155c565b610a2083836115a7565b610a2a83826115bd565b505050565b60006105de338484610dc4565b60006105fa610c84565b610aac87878787868689604051602001610a9893929190928352602083019190915260f81b7fff0000000000000000000000000000000000000000000000000000000000000016604082015260410190565b604051602081830303815290604052611442565b50505050505050565b60006105e233836115cf565b60003373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610b32576040517fb5f1e21f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61061b83836115cf565b60006105e2333384610e84565b60006105e2826113e5565b9055565b8273ffffffffffffffffffffffffffffffffffffffff8116610ba6576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116610bf4576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff85811660008181527feb877d33aaa0a9f80a1336db341e03580b8e117f72ae4da24f28b8d9f542cf246020908152604080832094891680845294825291829020879055815187815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a35050505050565b60006105fa7fbb529fb1cee654e97be26867c98d3c4533ccab25e5a26dbdc57e792087ed63415490565b6000610cdb7f0000000000000000000000000000000000000000000000000000000000000000600a612aae565b610ce3611620565b610ced9084612abd565b6105e29190612afa565b73ffffffffffffffffffffffffffffffffffffffff83811660009081527feb877d33aaa0a9f80a1336db341e03580b8e117f72ae4da24f28b8d9f542cf2460209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811415610d775750505050565b80821115610db1576040517fc213972500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610dbe8484848403610b58565b50505050565b8273ffffffffffffffffffffffffffffffffffffffff8116610e12576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116610e60576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610e6b8461140d565b9050610e788686836110f0565b610a0486868684611311565b600081610ebd576040517fa8d5202000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610eff73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168530856116b1565b610f09838361178d565b6000610f1483610cae565b905061071c6000858386611311565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610f8957507f000000000000000000000000000000000000000000000000000000000000000046145b15610fb357507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b600082611090576040517f3ea7667200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61109a8484611894565b6110a78460008486611311565b6110e873ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001685856119cf565b509092915050565b8273ffffffffffffffffffffffffffffffffffffffff811661113e576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff811661118c576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff84163014156111dc576040517f700b352200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff851660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d57560205260409020548084111561125a576040517eb284f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112648482612b35565b73ffffffffffffffffffffffffffffffffffffffff87811660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d575602052604080822093909355908716815220546112c0908590612b4c565b73ffffffffffffffffffffffffffffffffffffffff9590951660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d57560205260409020949094555050505050565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161137091815260200190565b60405180910390a38273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f9d9c909296d9c674451c0c24f02cb64981eb3b727f99865939192f880a755dcb836040516113d791815260200190565b60405180910390a350505050565b60007f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d575610761565b6000611417611620565b610ce37f0000000000000000000000000000000000000000000000000000000000000000600a612aae565b8142111561147c576040517f6015a46400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061150e7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98787876114ae83611a25565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810185905260e00160405160208183030381529060405280519060200120611ac2565b905061151b868284611b2b565b611551576040517f3f88fec700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a04868686611d1a565b611564610940565b1561159b576040517f61394a8400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115a481611d25565b50565b6115b082611d84565b6115b981611dee565b5050565b6115c682611e5f565b6115b981611e86565b600081611608576040517f0200905e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006116138361140d565b905061071c848285611057565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561168d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fa9190612b64565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052610dbe9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611ead565b8173ffffffffffffffffffffffffffffffffffffffff81166117db576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6117f6826117e7610c84565b6117f19190612b4c565b611fbe565b73ffffffffffffffffffffffffffffffffffffffff831660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d5756020526040902054611846908390612b4c565b73ffffffffffffffffffffffffffffffffffffffff9390931660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d57560205260409020929092555050565b8173ffffffffffffffffffffffffffffffffffffffff81166118e2576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d575602052604090205482811015611960576040517eb284f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119768361196c610c84565b6117f19190612b35565b6119808382612b35565b73ffffffffffffffffffffffffffffffffffffffff9490941660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d5756020526040902093909355505050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052610a2a9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161170b565b73ffffffffffffffffffffffffffffffffffffffff811660009081527fdaad28896b706a809236aec38dc84ce99b9d9cf68b8751e946a9258d6de2c8f16020526040902054611a75816001612b4c565b73ffffffffffffffffffffffffffffffffffffffff9290921660009081527fdaad28896b706a809236aec38dc84ce99b9d9cf68b8751e946a9258d6de2c8f1602052604090209190915590565b60006105e2611acf610f23565b836040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000806000611b3a8585611fe7565b90925090506000816004811115611b5357611b53612b7d565b148015611b8b57508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611b9b5760019250505061061b565b6000808773ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b8888604051602401611bd0929190612bac565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051611c599190612bc5565b600060405180830381855afa9150503d8060008114611c94576040519150601f19603f3d011682016040523d82523d6000602084013e611c99565b606091505b5091509150818015611cac575080516020145b8015611d0e575080517f1626ba7e0000000000000000000000000000000000000000000000000000000090611cea9083016020908101908401612be1565b7fffffffff0000000000000000000000000000000000000000000000000000000016145b98975050505050505050565b610a2a838383610b58565b611d4e7f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a6829055565b6040518181527ffddcded6b4f4730c226821172046b48372d3cd963c159701ae1b7c3bcac541bb9060200160405180910390a150565b8051611dbc576040517f348120a300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b807f3470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e5b81516115b992602001906123b9565b8051611e26576040517fa02a947f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b807f3470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e5b60010190805190602001906115b99291906123b9565b807f056ad441bfb3f4908fe527102b709e6e33a099187a55402844d65a5cc26af219611ddf565b807f056ad441bfb3f4908fe527102b709e6e33a099187a55402844d65a5cc26af219611e49565b6000611f0f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166120579092919063ffffffff16565b805190915015610a2a5780806020019051810190611f2d9190612c23565b610a2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6115a47fbb529fb1cee654e97be26867c98d3c4533ccab25e5a26dbdc57e792087ed6341829055565b60008082516041141561201e5760208301516040840151606085015160001a61201287828585612066565b94509450505050612050565b825160401415612048576020830151604084015161203d86838361217e565b935093505050612050565b506000905060025b9250929050565b606061071c84846000856121d0565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561209d5750600090506003612175565b8460ff16601b141580156120b557508460ff16601c14155b156120c65750600090506004612175565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561211a573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661216e57600060019250925050612175565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8316816121b460ff86901c601b612b4c565b90506121c287828885612066565b935093505050935093915050565b606082471015612262576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611fb5565b73ffffffffffffffffffffffffffffffffffffffff85163b6122e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611fb5565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516123099190612bc5565b60006040518083038185875af1925050503d8060008114612346576040519150601f19603f3d011682016040523d82523d6000602084013e61234b565b606091505b509150915061235b828286612366565b979650505050505050565b6060831561237557508161061b565b8251156123855782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fb591906124c8565b8280546123c59061290b565b90600052602060002090601f0160209004810192826123e7576000855561242d565b82601f1061240057805160ff191683800117855561242d565b8280016001018555821561242d579182015b8281111561242d578251825591602001919060010190612412565b5061243992915061243d565b5090565b5b80821115612439576000815560010161243e565b60005b8381101561246d578181015183820152602001612455565b83811115610dbe5750506000910152565b60008151808452612496816020860160208601612452565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061061b602083018461247e565b803573ffffffffffffffffffffffffffffffffffffffff811681146124ff57600080fd5b919050565b6000806040838503121561251757600080fd5b612520836124db565b946020939093013593505050565b60008060006060848603121561254357600080fd5b61254c846124db565b925061255a602085016124db565b9150604084013590509250925092565b60006020828403121561257c57600080fd5b5035919050565b60006020828403121561259557600080fd5b61061b826124db565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e0818401526125da60e084018a61247e565b83810360408501526125ec818a61247e565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c0860152855180825283870192509083019060005b8181101561264b5783518352928401929184019160010161262f565b50909c9b505050505050505050505050565b60008060008060008060a0878903121561267657600080fd5b61267f876124db565b955061268d602088016124db565b94506040870135935060608701359250608087013567ffffffffffffffff808211156126b857600080fd5b818901915089601f8301126126cc57600080fd5b8135818111156126db57600080fd5b8a60208285010111156126ed57600080fd5b6020830194508093505050509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261274357600080fd5b813567ffffffffffffffff8082111561275e5761275e612703565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156127a4576127a4612703565b816040528381528660208588010111156127bd57600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000606084860312156127f257600080fd5b833567ffffffffffffffff8082111561280a57600080fd5b61281687838801612732565b9450602086013591508082111561282c57600080fd5b61283887838801612732565b9350604086013591508082111561284e57600080fd5b5061285b86828701612732565b9150509250925092565b600080600080600080600060e0888a03121561288057600080fd5b612889886124db565b9650612897602089016124db565b95506040880135945060608801359350608088013560ff811681146128bb57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156128eb57600080fd5b6128f4836124db565b9150612902602084016124db565b90509250929050565b600181811c9082168061291f57607f821691505b60208210811415612959577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b808511156129e757817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156129cd576129cd61295f565b808516156129da57918102915b93841c9390800290612993565b509250929050565b6000826129fe575060016105e2565b81612a0b575060006105e2565b8160018114612a215760028114612a2b57612a47565b60019150506105e2565b60ff841115612a3c57612a3c61295f565b50506001821b6105e2565b5060208310610133831016604e8410600b8410161715612a6a575081810a6105e2565b612a74838361298e565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612aa657612aa661295f565b029392505050565b600061061b60ff8416836129ef565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612af557612af561295f565b500290565b600082612b30577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600082821015612b4757612b4761295f565b500390565b60008219821115612b5f57612b5f61295f565b500190565b600060208284031215612b7657600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b82815260406020820152600061071c604083018461247e565b60008251612bd7818460208701612452565b9190910192915050565b600060208284031215612bf357600080fd5b81517fffffffff000000000000000000000000000000000000000000000000000000008116811461061b57600080fd5b600060208284031215612c3557600080fd5b8151801515811461061b57600080fdfea2646970667358221220e8c4f9bb93ff4fed7cd8d8806689a723ebd4738e077d7220b8d811d9560b5cec64736f6c634300080a00333470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e056ad441bfb3f4908fe527102b709e6e33a099187a55402844d65a5cc26af21900000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000012000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a92001000000000000000000000000d835fac9080396cce95bdf9ecc7cc27bab12c9f80000000000000000000000001a513e9b6434a12c7bb5b9af3b21963308dee37200000000000000000000000000000000000000000000000000000000000000174c6971756964207374616b656420457468657220322e300000000000000000000000000000000000000000000000000000000000000000000000000000000005737445544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80638aa104351161010f578063c5ed7176116100a2578063de0e9a3e11610071578063de0e9a3e146104d4578063e53d44df146104e7578063ea598cb0146104fa578063f5eb42dc1461050d57600080fd5b8063c5ed71761461042d578063d5002f2e14610454578063d505accf1461045c578063dd62ed3e1461046f57600080fd5b8063a14a3a24116100de578063a14a3a24146103b9578063a6487c53146103e0578063a9059cbb146103f3578063b48b89b81461040657600080fd5b80638aa10435146103815780638fcb4e5b1461038957806395d89b411461039c5780639fd5a6cf146103a457600080fd5b806345a8306f1161018757806370a082311161015657806370a082311461032d5780637749c54f146103405780637ecebe001461035357806384b0196e1461036657600080fd5b806345a8306f146102a85780635290a4fa146102f45780636b37193c146103075780636d7804591461031a57600080fd5b806323b872dd116101c357806323b872dd146102415780632ed2493114610254578063313ce567146102675780633644e515146102a057600080fd5b806306fdde03146101ea578063095ea7b31461020857806318160ddd1461022b575b600080fd5b6101f2610520565b6040516101ff91906124c8565b60405180910390f35b61021b610216366004612504565b6105d1565b60405190151581526020016101ff565b6102336105e8565b6040519081526020016101ff565b61021b61024f36600461252e565b6105ff565b610233610262366004612504565b610622565b61028e7f000000000000000000000000000000000000000000000000000000000000001281565b60405160ff90911681526020016101ff565b6102336106be565b6102cf7f000000000000000000000000d835fac9080396cce95bdf9ecc7cc27bab12c9f881565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101ff565b61023361030236600461256a565b6106c8565b61023361031536600461256a565b6106d3565b61023361032836600461252e565b6106ec565b61023361033b366004612583565b610724565b61023361034e36600461256a565b610732565b610233610361366004612583565b61073d565b61036e61078d565b6040516101ff979695949392919061259e565b610233610940565b610233610397366004612504565b61096a565b6101f2610990565b6103b76103b236600461265d565b6109c1565b005b6102cf7f0000000000000000000000001a513e9b6434a12c7bb5b9af3b21963308dee37281565b6103b76103ee3660046127dd565b610a0c565b61021b610401366004612504565b610a2f565b61028e7f000000000000000000000000000000000000000000000000000000000000001b81565b6102cf7f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a9200181565b610233610a3c565b6103b761046a366004612865565b610a46565b61023361047d3660046128d8565b73ffffffffffffffffffffffffffffffffffffffff91821660009081527feb877d33aaa0a9f80a1336db341e03580b8e117f72ae4da24f28b8d9f542cf246020908152604080832093909416825291909152205490565b6102336104e236600461256a565b610ab5565b6102336104f5366004612504565b610ac1565b61023361050836600461256a565b610b3c565b61023361051b366004612583565b610b49565b60607f3470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e805461054e9061290b565b80601f016020809104026020016040519081016040528092919081815260200182805461057a9061290b565b80156105c75780601f1061059c576101008083540402835291602001916105c7565b820191906000526020600020905b8154815290600101906020018083116105aa57829003601f168201915b5050505050905090565b60006105de338484610b58565b5060015b92915050565b60006105fa6105f5610c84565b610cae565b905090565b600061060c843384610cf7565b610617848484610dc4565b5060015b9392505050565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000001a513e9b6434a12c7bb5b9af3b21963308dee3721614610693576040517fb5f1e21f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61061b7f0000000000000000000000001a513e9b6434a12c7bb5b9af3b21963308dee3728484610e84565b60006105fa610f23565b60006105e282610cae565b6000806106df83610cae565b905061061b338483611057565b6000806106f883610cae565b9050610705853383610cf7565b6107108585856110f0565b61071c85858386611311565b949350505050565b60006105e26105f5836113e5565b60006105e28261140d565b60007fdaad28896b706a809236aec38dc84ce99b9d9cf68b8751e946a9258d6de2c8f15b73ffffffffffffffffffffffffffffffffffffffff909216600090815260209290925250604090205490565b6000606080828080837f056ad441bfb3f4908fe527102b709e6e33a099187a55402844d65a5cc26af2198060010146306000806040519080825280602002602001820160405280156107e9578160200160208202803683370190505b507f0f0000000000000000000000000000000000000000000000000000000000000095949392919085805461081d9061290b565b80601f01602080910402602001604051908101604052809291908181526020018280546108499061290b565b80156108965780601f1061086b57610100808354040283529160200191610896565b820191906000526020600020905b81548152906001019060200180831161087957829003601f168201915b505050505095508480546108a99061290b565b80601f01602080910402602001604051908101604052809291908181526020018280546108d59061290b565b80156109225780601f106108f757610100808354040283529160200191610922565b820191906000526020600020905b81548152906001019060200180831161090557829003601f168201915b50505050509450965096509650965096509650965090919293949596565b60006105fa7f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a65490565b60006109773384846110f0565b600061098283610cae565b905061061b33858386611311565b60607f3470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e600101805461054e9061290b565b610a048686868686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061144292505050565b505050505050565b610a16600161155c565b610a2083836115a7565b610a2a83826115bd565b505050565b60006105de338484610dc4565b60006105fa610c84565b610aac87878787868689604051602001610a9893929190928352602083019190915260f81b7fff0000000000000000000000000000000000000000000000000000000000000016604082015260410190565b604051602081830303815290604052611442565b50505050505050565b60006105e233836115cf565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000001a513e9b6434a12c7bb5b9af3b21963308dee3721614610b32576040517fb5f1e21f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61061b83836115cf565b60006105e2333384610e84565b60006105e2826113e5565b9055565b8273ffffffffffffffffffffffffffffffffffffffff8116610ba6576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116610bf4576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff85811660008181527feb877d33aaa0a9f80a1336db341e03580b8e117f72ae4da24f28b8d9f542cf246020908152604080832094891680845294825291829020879055815187815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a35050505050565b60006105fa7fbb529fb1cee654e97be26867c98d3c4533ccab25e5a26dbdc57e792087ed63415490565b6000610cdb7f000000000000000000000000000000000000000000000000000000000000001b600a612aae565b610ce3611620565b610ced9084612abd565b6105e29190612afa565b73ffffffffffffffffffffffffffffffffffffffff83811660009081527feb877d33aaa0a9f80a1336db341e03580b8e117f72ae4da24f28b8d9f542cf2460209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811415610d775750505050565b80821115610db1576040517fc213972500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610dbe8484848403610b58565b50505050565b8273ffffffffffffffffffffffffffffffffffffffff8116610e12576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff8116610e60576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610e6b8461140d565b9050610e788686836110f0565b610a0486868684611311565b600081610ebd576040517fa8d5202000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610eff73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a92001168530856116b1565b610f09838361178d565b6000610f1483610cae565b905061071c6000858386611311565b60003073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005a007d6e37633fb297b82c074b94bb29546bebc316148015610f8957507f000000000000000000000000000000000000000000000000000000000000008246145b15610fb357507fcd51a829b13f67203eed125ea47b0b3673272c0784a6de8b7dc5cbc59f90c06a90565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527fd0475442dbe1381d44afad818dc97da0a5b374312c7fe323cc2a3df88293e4ba828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b600082611090576040517f3ea7667200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61109a8484611894565b6110a78460008486611311565b6110e873ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a920011685856119cf565b509092915050565b8273ffffffffffffffffffffffffffffffffffffffff811661113e576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff811661118c576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff84163014156111dc576040517f700b352200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff851660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d57560205260409020548084111561125a576040517eb284f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112648482612b35565b73ffffffffffffffffffffffffffffffffffffffff87811660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d575602052604080822093909355908716815220546112c0908590612b4c565b73ffffffffffffffffffffffffffffffffffffffff9590951660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d57560205260409020949094555050505050565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161137091815260200190565b60405180910390a38273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f9d9c909296d9c674451c0c24f02cb64981eb3b727f99865939192f880a755dcb836040516113d791815260200190565b60405180910390a350505050565b60007f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d575610761565b6000611417611620565b610ce37f000000000000000000000000000000000000000000000000000000000000001b600a612aae565b8142111561147c576040517f6015a46400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061150e7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98787876114ae83611a25565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810185905260e00160405160208183030381529060405280519060200120611ac2565b905061151b868284611b2b565b611551576040517f3f88fec700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a04868686611d1a565b611564610940565b1561159b576040517f61394a8400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115a481611d25565b50565b6115b082611d84565b6115b981611dee565b5050565b6115c682611e5f565b6115b981611e86565b600081611608576040517f0200905e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006116138361140d565b905061071c848285611057565b60007f000000000000000000000000d835fac9080396cce95bdf9ecc7cc27bab12c9f873ffffffffffffffffffffffffffffffffffffffff166350d25bcd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561168d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105fa9190612b64565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052610dbe9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611ead565b8173ffffffffffffffffffffffffffffffffffffffff81166117db576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6117f6826117e7610c84565b6117f19190612b4c565b611fbe565b73ffffffffffffffffffffffffffffffffffffffff831660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d5756020526040902054611846908390612b4c565b73ffffffffffffffffffffffffffffffffffffffff9390931660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d57560205260409020929092555050565b8173ffffffffffffffffffffffffffffffffffffffff81166118e2576040517fef6b416200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d575602052604090205482811015611960576040517eb284f200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119768361196c610c84565b6117f19190612b35565b6119808382612b35565b73ffffffffffffffffffffffffffffffffffffffff9490941660009081527f86aa1dcd67d862576fe9ed9ba39f757969f4787f57a2c884bc4bb79c1992d5756020526040902093909355505050565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052610a2a9084907fa9059cbb000000000000000000000000000000000000000000000000000000009060640161170b565b73ffffffffffffffffffffffffffffffffffffffff811660009081527fdaad28896b706a809236aec38dc84ce99b9d9cf68b8751e946a9258d6de2c8f16020526040902054611a75816001612b4c565b73ffffffffffffffffffffffffffffffffffffffff9290921660009081527fdaad28896b706a809236aec38dc84ce99b9d9cf68b8751e946a9258d6de2c8f1602052604090209190915590565b60006105e2611acf610f23565b836040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000806000611b3a8585611fe7565b90925090506000816004811115611b5357611b53612b7d565b148015611b8b57508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b15611b9b5760019250505061061b565b6000808773ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b8888604051602401611bd0929190612bac565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051611c599190612bc5565b600060405180830381855afa9150503d8060008114611c94576040519150601f19603f3d011682016040523d82523d6000602084013e611c99565b606091505b5091509150818015611cac575080516020145b8015611d0e575080517f1626ba7e0000000000000000000000000000000000000000000000000000000090611cea9083016020908101908401612be1565b7fffffffff0000000000000000000000000000000000000000000000000000000016145b98975050505050505050565b610a2a838383610b58565b611d4e7f4dd0f6662ba1d6b081f08b350f5e9a6a7b15cf586926ba66f753594928fa64a6829055565b6040518181527ffddcded6b4f4730c226821172046b48372d3cd963c159701ae1b7c3bcac541bb9060200160405180910390a150565b8051611dbc576040517f348120a300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b807f3470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e5b81516115b992602001906123b9565b8051611e26576040517fa02a947f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b807f3470f8373d566de7ab61e14a030ae865a1f164b610b931eb8aa08ad044e2e68e5b60010190805190602001906115b99291906123b9565b807f056ad441bfb3f4908fe527102b709e6e33a099187a55402844d65a5cc26af219611ddf565b807f056ad441bfb3f4908fe527102b709e6e33a099187a55402844d65a5cc26af219611e49565b6000611f0f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166120579092919063ffffffff16565b805190915015610a2a5780806020019051810190611f2d9190612c23565b610a2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6115a47fbb529fb1cee654e97be26867c98d3c4533ccab25e5a26dbdc57e792087ed6341829055565b60008082516041141561201e5760208301516040840151606085015160001a61201287828585612066565b94509450505050612050565b825160401415612048576020830151604084015161203d86838361217e565b935093505050612050565b506000905060025b9250929050565b606061071c84846000856121d0565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561209d5750600090506003612175565b8460ff16601b141580156120b557508460ff16601c14155b156120c65750600090506004612175565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561211a573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811661216e57600060019250925050612175565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8316816121b460ff86901c601b612b4c565b90506121c287828885612066565b935093505050935093915050565b606082471015612262576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611fb5565b73ffffffffffffffffffffffffffffffffffffffff85163b6122e0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611fb5565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516123099190612bc5565b60006040518083038185875af1925050503d8060008114612346576040519150601f19603f3d011682016040523d82523d6000602084013e61234b565b606091505b509150915061235b828286612366565b979650505050505050565b6060831561237557508161061b565b8251156123855782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fb591906124c8565b8280546123c59061290b565b90600052602060002090601f0160209004810192826123e7576000855561242d565b82601f1061240057805160ff191683800117855561242d565b8280016001018555821561242d579182015b8281111561242d578251825591602001919060010190612412565b5061243992915061243d565b5090565b5b80821115612439576000815560010161243e565b60005b8381101561246d578181015183820152602001612455565b83811115610dbe5750506000910152565b60008151808452612496816020860160208601612452565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061061b602083018461247e565b803573ffffffffffffffffffffffffffffffffffffffff811681146124ff57600080fd5b919050565b6000806040838503121561251757600080fd5b612520836124db565b946020939093013593505050565b60008060006060848603121561254357600080fd5b61254c846124db565b925061255a602085016124db565b9150604084013590509250925092565b60006020828403121561257c57600080fd5b5035919050565b60006020828403121561259557600080fd5b61061b826124db565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e0818401526125da60e084018a61247e565b83810360408501526125ec818a61247e565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c0860152855180825283870192509083019060005b8181101561264b5783518352928401929184019160010161262f565b50909c9b505050505050505050505050565b60008060008060008060a0878903121561267657600080fd5b61267f876124db565b955061268d602088016124db565b94506040870135935060608701359250608087013567ffffffffffffffff808211156126b857600080fd5b818901915089601f8301126126cc57600080fd5b8135818111156126db57600080fd5b8a60208285010111156126ed57600080fd5b6020830194508093505050509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261274357600080fd5b813567ffffffffffffffff8082111561275e5761275e612703565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156127a4576127a4612703565b816040528381528660208588010111156127bd57600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000606084860312156127f257600080fd5b833567ffffffffffffffff8082111561280a57600080fd5b61281687838801612732565b9450602086013591508082111561282c57600080fd5b61283887838801612732565b9350604086013591508082111561284e57600080fd5b5061285b86828701612732565b9150509250925092565b600080600080600080600060e0888a03121561288057600080fd5b612889886124db565b9650612897602089016124db565b95506040880135945060608801359350608088013560ff811681146128bb57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b600080604083850312156128eb57600080fd5b6128f4836124db565b9150612902602084016124db565b90509250929050565b600181811c9082168061291f57607f821691505b60208210811415612959577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b808511156129e757817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048211156129cd576129cd61295f565b808516156129da57918102915b93841c9390800290612993565b509250929050565b6000826129fe575060016105e2565b81612a0b575060006105e2565b8160018114612a215760028114612a2b57612a47565b60019150506105e2565b60ff841115612a3c57612a3c61295f565b50506001821b6105e2565b5060208310610133831016604e8410600b8410161715612a6a575081810a6105e2565b612a74838361298e565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612aa657612aa661295f565b029392505050565b600061061b60ff8416836129ef565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612af557612af561295f565b500290565b600082612b30577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600082821015612b4757612b4761295f565b500390565b60008219821115612b5f57612b5f61295f565b500190565b600060208284031215612b7657600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b82815260406020820152600061071c604083018461247e565b60008251612bd7818460208701612452565b9190910192915050565b600060208284031215612bf357600080fd5b81517fffffffff000000000000000000000000000000000000000000000000000000008116811461061b57600080fd5b600060208284031215612c3557600080fd5b8151801515811461061b57600080fdfea2646970667358221220e8c4f9bb93ff4fed7cd8d8806689a723ebd4738e077d7220b8d811d9560b5cec64736f6c634300080a0033

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

00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000012000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a92001000000000000000000000000d835fac9080396cce95bdf9ecc7cc27bab12c9f80000000000000000000000001a513e9b6434a12c7bb5b9af3b21963308dee37200000000000000000000000000000000000000000000000000000000000000174c6971756964207374616b656420457468657220322e300000000000000000000000000000000000000000000000000000000000000000000000000000000005737445544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : name_ (string): Liquid staked Ether 2.0
Arg [1] : symbol_ (string): stETH
Arg [2] : version_ (string): 1
Arg [3] : decimals_ (uint8): 18
Arg [4] : tokenToWrapFrom_ (address): 0xc02fE7317D4eb8753a02c35fe019786854A92001
Arg [5] : tokenRateOracle_ (address): 0xD835fAC9080396CCE95bDf9EcC7cc27Bab12c9f8
Arg [6] : bridge_ (address): 0x1A513e9B6434a12C7bB5B9AF3B21963308DEE372

-----Encoded View---------------
13 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000160
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000012
Arg [4] : 000000000000000000000000c02fe7317d4eb8753a02c35fe019786854a92001
Arg [5] : 000000000000000000000000d835fac9080396cce95bdf9ecc7cc27bab12c9f8
Arg [6] : 0000000000000000000000001a513e9b6434a12c7bb5b9af3b21963308dee372
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000017
Arg [8] : 4c6971756964207374616b656420457468657220322e30000000000000000000
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [10] : 7374455448000000000000000000000000000000000000000000000000000000
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [12] : 3100000000000000000000000000000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.