HYPE Price: $24.97 (+12.77%)
 

Overview

HYPE Balance

HyperEVM LogoHyperEVM LogoHyperEVM Logo0 HYPE

HYPE Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Create Distribut...220113432025-12-16 16:55:0041 days ago1765904100IN
0x4C79d66D...28AD75CC4
0 HYPE0.000312760.1
Create Distribut...169922892025-10-20 13:26:0098 days ago1760966760IN
0x4C79d66D...28AD75CC4
0 HYPE0.000225450.1
Create Distribut...169914962025-10-20 13:13:0098 days ago1760965980IN
0x4C79d66D...28AD75CC4
0 HYPE0.000325750.1
Create Distribut...126218842025-08-31 19:11:00148 days ago1756667460IN
0x4C79d66D...28AD75CC4
0 HYPE0.000246760.1
Create Distribut...41577442025-05-22 7:26:00249 days ago1747898760IN
0x4C79d66D...28AD75CC4
0 HYPE0.000311590.1
Create Distribut...39415192025-05-17 11:09:00254 days ago1747480140IN
0x4C79d66D...28AD75CC4
0 HYPE0.000166130.1
Create Distribut...39410852025-05-17 10:55:00254 days ago1747479300IN
0x4C79d66D...28AD75CC4
0 HYPE0.000166130.1

Latest 8 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
220113432025-12-16 16:55:0041 days ago1765904100
0x4C79d66D...28AD75CC4
 Contract Creation0 HYPE
169922892025-10-20 13:26:0098 days ago1760966760
0x4C79d66D...28AD75CC4
 Contract Creation0 HYPE
169914962025-10-20 13:13:0098 days ago1760965980
0x4C79d66D...28AD75CC4
 Contract Creation0 HYPE
126218842025-08-31 19:11:00148 days ago1756667460
0x4C79d66D...28AD75CC4
 Contract Creation0 HYPE
41577442025-05-22 7:26:00249 days ago1747898760
0x4C79d66D...28AD75CC4
 Contract Creation0 HYPE
39415192025-05-17 11:09:00254 days ago1747480140
0x4C79d66D...28AD75CC4
 Contract Creation0 HYPE
39410852025-05-17 10:55:00254 days ago1747479300
0x4C79d66D...28AD75CC4
 Contract Creation0 HYPE
39170292025-05-16 21:59:00255 days ago1747432740
0x4C79d66D...28AD75CC4
 Contract Creation0 HYPE
Cross-Chain Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xa7E10b03...716ba9dF6 in BNB Smart Chain Mainnet
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
DistributorFactory

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

import {AccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import {Versioned} from "echo/Versioned.sol";
import {IGenericRegistry} from "echo/interfaces/IGenericRegistry.sol";

import {Distributor} from "./Distributor.sol";
import {newDistributor} from "./Deploy.sol";
import {UnlockerLib} from "./UnlockerLib.sol";
import "./Types.sol";

/// @notice Factory for creating unlocked token distributors.
contract DistributorFactory is AccessControlEnumerable, Versioned(2, 0, 0) {
    /// @notice Emitted when a distributor is created
    event DistributorCreated(bytes16 indexed tokenDistributionUUID, address indexed distributorAddress);

    /// @notice Role allowed to change settings on this contract
    /// @dev This is intended to be controlled by the IM team.
    bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

    /// @notice The role allowed to grant ENG_MANAGER_ROLE
    /// @dev This is intended to be controlled by the ENG multisig.
    bytes32 public constant ENG_ADMIN_ROLE = keccak256("ENG_ADMIN_ROLE");

    /// @notice The role allowed to manage engineering related aspects of the contract, that does not involve any funds.
    /// @dev This is intended to be controlled by the ENG team.
    bytes32 public constant ENG_MANAGER_ROLE = keccak256("ENG_MANAGER_ROLE");

    /// @notice Role granted to the platform, allowed to create distributors
    /// @dev This is intended to be controlled by the platform backend.
    bytes32 public constant PLATFORM_ROLE = keccak256("PLATFORM_ROLE");

    /// @notice Fixed parameters specified by the IM team used to initialize distributors created by this factory
    IMFixedDistributorCreationParams public imFixedDistributorCreationParams;

    /// @notice Fixed parameters specified by the ENG team used to initialize distributors created by this factory
    ENGFixedDistributorCreationParams public engFixedDistributorCreationParams;

    /// @notice Address of the implementation for new distributors
    address public distributorImpl;

    /// @notice Fixed parameters specified by the IM team used to initialize distributors created by this factory
    /// @dev These parameters are not expected to change for different distributors.
    /// They are used together with variable parameters sent to `createDistributor` by the platfrom backend to initialize distributors created by this factory
    /// @dev Since some of these parameters are sensitive, we don't allow the platform or the ENG team to pass them in or change them, and store them in this contract instead.
    struct IMFixedDistributorCreationParams {
        address adminIM;
        address managerIM;
        address adminENG;
        IGenericRegistry genericRegistry;
    }

    /// @notice Fixed parameters specified by the ENG team used to initialize distributors created by this factory
    /// @dev These parameters are not expected to change for different distributors.
    /// They are used together with variable parameters sent to `createDistributor` by the platfrom backend to initialize distributors created by this factory
    /// @dev Since some of these parameters are sensitive, we don't allow the platform to pass them in or change them, and store them in this contract instead.
    struct ENGFixedDistributorCreationParams {
        address managerENG;
        address platformSigner;
        address platformSender;
    }

    /// @notice Dynamic parameters used to initialize a new distributor
    /// @dev These parameters are sent to `createDistributor` to initialize a new distributor and can be different for each distributor
    struct VariableDistributorCreationParams {
        IERC20 token;
        bytes16 tokenDistributionUUID;
        UnlockerLib.Unlocker unlocker;
        Claimer[] claimers;
        CarryWithdrawer[] carryWithdrawers;
        bytes32 expectedClaimersRoot;
        uint16 platformCarryBPS;
    }

    struct Init {
        address adminIM;
        address adminENG;
        address platform;
        IMFixedDistributorCreationParams imFixedDistributorCreationParams;
        ENGFixedDistributorCreationParams engFixedDistributorCreationParams;
    }

    constructor(Init memory init) {
        _setRoleAdmin(ENG_MANAGER_ROLE, ENG_ADMIN_ROLE);
        _setRoleAdmin(PLATFORM_ROLE, ENG_MANAGER_ROLE);

        _grantRole(DEFAULT_ADMIN_ROLE, init.adminIM);
        _grantRole(MANAGER_ROLE, init.adminIM);

        _grantRole(ENG_ADMIN_ROLE, init.adminENG);
        _grantRole(ENG_MANAGER_ROLE, init.adminENG);

        _grantRole(PLATFORM_ROLE, init.platform);

        imFixedDistributorCreationParams = init.imFixedDistributorCreationParams;
        engFixedDistributorCreationParams = init.engFixedDistributorCreationParams;

        distributorImpl = address(new Distributor());
    }

    /// @notice Creates a new distributor
    /// @param params Variable parameters used to initialize the new distributor
    /// @return The address of the newly created distributor
    function createDistributor(VariableDistributorCreationParams memory params)
        external
        onlyRole(PLATFORM_ROLE)
        returns (Distributor)
    {
        Distributor distributor = newDistributor(
            imFixedDistributorCreationParams.adminIM,
            Distributor(distributorImpl),
            Distributor.Init({
                // variable params
                token: params.token,
                tokenDistributionUUID: params.tokenDistributionUUID,
                unlocker: params.unlocker,
                claimers: params.claimers,
                carryWithdrawers: params.carryWithdrawers,
                expectedClaimersRoot: params.expectedClaimersRoot,
                platformCarryBPS: params.platformCarryBPS,
                // IM fixed params
                genericRegistry: imFixedDistributorCreationParams.genericRegistry,
                adminIM: imFixedDistributorCreationParams.adminIM,
                managerIM: imFixedDistributorCreationParams.managerIM,
                adminENG: imFixedDistributorCreationParams.adminENG,
                // ENG fixed params
                managerENG: engFixedDistributorCreationParams.managerENG,
                platformSigner: engFixedDistributorCreationParams.platformSigner,
                platformSender: engFixedDistributorCreationParams.platformSender
            })
        );

        emit DistributorCreated(params.tokenDistributionUUID, address(distributor));

        return distributor;
    }

    // TODO emit config changed events

    /// @notice Sets the implementation for new distributors
    /// @param newImpl The address of the new implementation
    function setDistributorImplementation(address newImpl) external onlyRole(MANAGER_ROLE) {
        distributorImpl = newImpl;
    }

    /// @notice Sets the IM fixed parameters for new distributors
    /// @param newParams The fixed parameters
    function setIMFixedDistributorCreationParams(IMFixedDistributorCreationParams memory newParams)
        external
        onlyRole(MANAGER_ROLE)
    {
        imFixedDistributorCreationParams = newParams;
    }

    /// @notice Sets the ENG fixed parameters for new distributors
    /// @param newParams The fixed parameters
    function setENGFixedDistributorCreationParams(ENGFixedDistributorCreationParams memory newParams)
        external
        onlyRole(ENG_MANAGER_ROLE)
    {
        engFixedDistributorCreationParams = newParams;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)

pragma solidity ^0.8.20;

import {IAccessControlEnumerable} from "./IAccessControlEnumerable.sol";
import {AccessControl} from "../AccessControl.sol";
import {EnumerableSet} from "../../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

    mapping(bytes32 role => EnumerableSet.AddressSet) private _roleMembers;

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

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

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

    /**
     * @dev Overload {AccessControl-_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
        bool granted = super._grantRole(role, account);
        if (granted) {
            _roleMembers[role].add(account);
        }
        return granted;
    }

    /**
     * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
        bool revoked = super._revokeRole(role, account);
        if (revoked) {
            _roleMembers[role].remove(account);
        }
        return revoked;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 4 of 46 : Versioned.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

/// @title Versioned
/// @notice A base contract for version control
/// @dev This contract MUST only contain immutable state, since we will also use it for upgradeable contracts.
contract Versioned {
    uint32 private immutable _major;
    uint32 private immutable _minor;
    uint32 private immutable _patch;

    constructor(uint32 major, uint32 minor, uint32 patch) {
        _major = major;
        _minor = minor;
        _patch = patch;
    }

    function version() external view returns (uint32, uint32, uint32) {
        return (_major, _minor, _patch);
    }
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

interface IGenericRegistry {
    function setBytes32(bytes32 key, bytes32 value) external;
    function setAddress(bytes32 key, address value) external;
    function setUint256(bytes32 key, uint256 value) external;
    function setInt256(bytes32 key, int256 value) external;
    function setBool(bytes32 key, bool value) external;

    function readBytes32(bytes32 key) external view returns (bytes32);
    function readAddress(bytes32 key) external view returns (address);
    function readUint256(bytes32 key) external view returns (uint256);
    function readInt256(bytes32 key) external view returns (int256);
    function readBool(bytes32 key) external view returns (bool);
}

File 6 of 46 : Distributor.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {AccessControlEnumerableUpgradeable} from
    "@openzeppelin/contracts-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol";
import {EIP712Upgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";

import {ConfigChanged} from "echo/interfaces/PlatformEvents.sol";
import {Merkle} from "echo/Merkle.sol";
import {IGenericRegistry} from "echo/interfaces/IGenericRegistry.sol";
import {GenericRegistryKeys} from "echo/interfaces/GenericRegistryKeys.sol";
import "./Types.sol";
import {UnlockerLib} from "./UnlockerLib.sol";
import {Versioned} from "echo/Versioned.sol";

/// @title Distributor
contract Distributor is Initializable, AccessControlEnumerableUpgradeable, EIP712Upgradeable, Versioned(2, 0, 0) {
    using SafeERC20 for IERC20;
    using PriceLib for Price;

    /// @notice The role allowed to manage any funds related aspects of the contract
    /// @dev This is intended to be controlled by the IM team.
    bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

    /// @notice The role allowed to grant ENG_MANAGER_ROLE
    /// @dev This is intended to be controlled by the ENG multisig.
    bytes32 public constant ENG_ADMIN_ROLE = keccak256("ENG_ADMIN_ROLE");

    /// @notice The role allowed to manage engineering related aspects of the contract, that does not involve any funds.
    /// @dev This is intended to be controlled by the ENG team.
    bytes32 public constant ENG_MANAGER_ROLE = keccak256("ENG_MANAGER_ROLE");

    /// @notice The role allowed to trigger a withdrawal of the platform carry.
    /// @dev This is intended to be controlled by the platform backend.
    bytes32 public constant PLATFORM_CARRY_WITHDRAWER_ROLE = keccak256("PLATFORM_CARRY_WITHDRAWER_ROLE");

    /// @notice The role allowed to prefill data for the platform carry.
    /// @dev This is intended to be controlled by the platform backend.
    bytes32 public constant PLATFORM_ROLE = keccak256("PLATFORM_ROLE");

    /// @notice The role allowed to sign claim data.
    /// @dev This is intended to be controlled by the platform backend.
    bytes32 public constant SIGNER_ROLE = keccak256("SIGNER_ROLE");

    /// @notice The role allowed to pause token claims and carry withdrawals.
    /// @dev This is intended to be controlled by the platform backend.
    /// @dev Keeping this deliberately separate from the `PLATFORM_CARRY_WITHDRAWER_ROLE` since we might want to grant this to some external monitoring in the future
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    /// @notice The role allowed to prefill state data for the distributor.
    /// @dev A prefill is a one-time operation that sets the state of the distributor to some provided data before enabling any claims or withdrawals.
    /// This is required if we need to migrate a distribution to another chain and resume it there, e.g. because the project migrated.
    /// The intended process is:
    /// 1. The manager grants the PREFILL_ROLE to a platform operator (can be the backend or some manual operator).
    /// 2. The operator calls `prefillClaimerStates` with the desired data -- the data can be provided in chunks if needed.
    /// 3. The operator calls `addCarryWithdrawerStates` with the desired data -- the data can be provided in chunks if needed.
    /// 4. The operator calls `finalizePrefill` to mark the prefill as complete, which renounces the PREFILL_ROLE.
    bytes32 public constant PREFILL_ROLE = keccak256("PREFILL_ROLE");

    /// @dev The entity UUID for the platform. Note that the platform does **not** have actually have a UUID in our system.
    /// This is an implementation detail to ensure our carry calculation bookkeeping matches other carry receivers.
    bytes16 internal constant PLATFORM_ENTITY_UUID = bytes16(0);

    error InvalidConfiguration(string);
    error DuplicateUser(bytes16 entityUUID);
    error DuplicateCarryWithdrawer(bytes16 entityUUID);
    error CallerNotAllowed(address sender, bytes16 entityUUID, address signer);
    error UnauthorizedPlatformSigner(address signer);
    error UnauthorizedUserSigner(address got, address want);
    error UnknownUser();
    error ClaimExpired(uint256 expiredAt);
    error AmountExceedsClaimable(uint256 amount, uint256 claimableAmount);
    error AmountExceedsWithdrawableCarry(uint256 amount, uint256 withdrawableAmount);
    error WrongTokenDistribution(bytes16 got, bytes16 want);
    error UnexpectedClaimerMerkleRoot(bytes32[] leafs, bytes32 got, bytes32 want);
    error InvalidClaimerMerkleProof(bytes32 leaf, bytes32 got, bytes32 want);
    error Disabled();
    error InvalidClaimerState(bytes16 entityUUID);
    error ClaimerStateAlreadySet(bytes16 entityUUID);
    error WithdrawerStateAlreadySet(bytes16 entityUUID);
    error InvalidPrefillExpectedValue(string name, uint256 got, uint256 want);

    event Claimed(
        bytes16 indexed tokenDistributionUUID,
        bytes16 indexed entityUUID,
        address indexed receiver,
        uint256 amount,
        uint256 amountUSDC,
        uint256 amountCarry
    );

    event CarryWithdrawn(
        bytes16 indexed tokenDistributionUUID, bytes16 indexed entityUUID, address indexed receiver, uint256 amount
    );

    struct ClaimerState {
        uint256 amountClaimed;
        uint64 amountClaimedUSDC;
    }

    /// @dev Equivalent to CarryWithdrawer, but without the entity UUID since we will have it as key on the mapping.
    struct CarryWithdrawerWithoutUUID {
        address signer;
        uint16 carryBPS;
    }

    /// @notice The UnlockWallet provided by the project that gradually unlocks SPV assets.
    UnlockerLib.Unlocker public unlocker;

    /// @notice The GenericRegistry contract which stores the platform specific carry receiver.
    IGenericRegistry public genericRegistry;

    /// @notice  The token that will be unlocked/released.
    IERC20 public token;

    /// @notice Flag to enable/disable token claims and carry withdrawals.
    bool public isEnabled;

    /// @notice Flag to enable/disable the forced distribution mode.
    /// @dev When enabled, the token claim and carry withdrawal functions do not require signatures from the user signer.
    bool public isForcedDistributionModeEnabled;

    /// @notice The UUID of the token distribution.
    bytes16 public tokenDistributionUUID;

    /// @notice  The total amount of distribution shares for the SPV across all users.
    /// @dev This is the sum of all `distributionShares` in `usersSettings`.
    /// @dev It is used to compute the relative share of the total unlocked tokens for each state. It is derived from
    /// the users's ownership of the SPV.
    uint64 public totalDistributionShares;

    /// @notice The total carry in basis points.
    uint16 public totalCarryBPS;

    /// @notice The total amount of tokens claimed by users.
    uint256 public totalClaimed;

    /// @notice The total amount of carry that has been generated, i.e. deducted from user's claims.
    uint256 public totalCarryGenerated;

    /// @notice The total amount of carry withdrawn by carry receivers.
    uint256 public totalCarryWithdrawn;

    /// @notice The carry for the platform in basis points.
    uint16 public platformCarryBPS;

    /// @notice Tracks the amount of tokens each user has already claimed.
    mapping(bytes16 => ClaimerState) private _claimerState;

    /// @notice Tracks the amount of carry each carry withdrawer has withdrawn.
    /// @dev This also keeps track of the platform carry under the PLATFORM_ENTITY_UUID key.
    mapping(bytes16 => uint256) private _carryAmountWithdrawn;

    /// @notice The root of the claimers merkle tree.
    bytes32 public claimersRoot;

    /// @notice Tracks settings for carry withdrawers.
    /// @dev This does not include settings for the platform carry.
    mapping(bytes16 => CarryWithdrawerWithoutUUID) private _carryWithdrawers;

    /// @notice The UUIDs of the carry receivers.
    bytes16[] private _carryWithdrawerUUIDs;

    struct Init {
        IERC20 token;
        bytes16 tokenDistributionUUID;
        UnlockerLib.Unlocker unlocker;
        IGenericRegistry genericRegistry;
        Claimer[] claimers;
        CarryWithdrawer[] carryWithdrawers;
        address adminIM;
        address managerIM;
        address adminENG;
        address managerENG;
        address platformSigner;
        address platformSender;
        bytes32 expectedClaimersRoot;
        uint16 platformCarryBPS;
    }

    constructor() {
        _disableInitializers();
    }

    function initialize(Init memory init) external initializer {
        __AccessControlEnumerable_init();
        __EIP712_init("Distributor", "1");

        _setRoleAdmin(ENG_MANAGER_ROLE, ENG_ADMIN_ROLE);
        _setRoleAdmin(SIGNER_ROLE, ENG_MANAGER_ROLE);
        _setRoleAdmin(PLATFORM_CARRY_WITHDRAWER_ROLE, ENG_MANAGER_ROLE);

        // granting IM roles
        _grantRole(DEFAULT_ADMIN_ROLE, init.adminIM);
        _grantRole(MANAGER_ROLE, init.managerIM);

        // granting ENG roles
        _grantRole(ENG_ADMIN_ROLE, init.adminENG);
        _grantRole(ENG_MANAGER_ROLE, init.managerENG);

        // granting platform roles
        _grantRole(SIGNER_ROLE, init.platformSigner);
        _grantRole(PLATFORM_CARRY_WITHDRAWER_ROLE, init.platformSender);
        _grantRole(PLATFORM_ROLE, init.platformSender);
        _grantRole(PAUSER_ROLE, init.platformSender);

        UnlockerLib.validate(init.unlocker);
        unlocker = init.unlocker;
        genericRegistry = init.genericRegistry;
        token = init.token;
        tokenDistributionUUID = init.tokenDistributionUUID;
        platformCarryBPS = init.platformCarryBPS;

        _setClaimers(init.claimers, init.expectedClaimersRoot);
        _setCarryWithdrawerSettings(init.carryWithdrawers);
        isEnabled = true;
    }

    /// @notice Returns the domain separator for this contract.
    function domainSeparator() external view returns (bytes32) {
        return _domainSeparatorV4();
    }

    function claimerStates(bytes16[] calldata entityUUID) external view returns (ClaimerState[] memory) {
        ClaimerState[] memory ret = new ClaimerState[](entityUUID.length);
        for (uint256 i = 0; i < entityUUID.length; i++) {
            ret[i] = _claimerState[entityUUID[i]];
        }
        return ret;
    }

    function claimed(bytes16[] calldata entityUUID) external view returns (uint256[] memory) {
        uint256[] memory ret = new uint256[](entityUUID.length);
        for (uint256 i = 0; i < entityUUID.length; i++) {
            ret[i] = _claimerState[entityUUID[i]].amountClaimed;
        }
        return ret;
    }

    /// @notice Pulls the unlocked tokens from the unlock wallet.
    /// @dev This function can be called by anyone to pull the unlocked tokens from the unlock wallet at any point. However, we commonly expect
    /// it be called when a user claims their tokens.
    function pullUnlockedTokens() public {
        UnlockerLib.release(unlocker);
    }

    /// @notice Claims tokens for a given user. Requires valid signatures of the claim data (user + platform).
    /// @dev The function needs two valid signatures of the claim data (user + platform) to authorize a claim.
    /// There is no additional access control on the function, which allows anyone to execute a claim as long as the signatures are valid.
    /// We chose this approach as it gives us ultimate flexibility in who executes the transaction,
    /// e.g. it could either be send by the user on the frontend or by the platform backend.
    /// Does not require claimer signature if the contract has the`forcedDistributionModeEnabled` flag enabled.
    /// @param claimData The claim data that is signed by the user and the platform.
    /// @param claimSignatureUser The signature of the claim data by the user (EIP-712).
    /// @param claimSignaturePlatform The signature of the claim data by the platform (EIP-712).
    /// @param user The user settings that are used in the merkle proof.
    /// @param merkleProof The merkle proof that is used to verify the user's settings in the merkle tree.
    /// @param pullUnlocked Whether to pull the unlocked tokens from the unlocker contract.
    function claim(
        ClaimData calldata claimData,
        bytes calldata claimSignatureUser,
        bytes calldata claimSignaturePlatform,
        Claimer calldata user,
        bytes32[] calldata merkleProof,
        bool pullUnlocked
    ) external onlyIf(isEnabled) {
        if (pullUnlocked) {
            pullUnlockedTokens();
        }

        _release(claimData, claimSignatureUser, claimSignaturePlatform, user, merkleProof);
    }

    function _release(
        ClaimData calldata claimData,
        bytes calldata claimSignatureUser,
        bytes calldata claimSignaturePlatform,
        Claimer calldata user,
        bytes32[] calldata merkleProof
    ) internal {
        if (claimData.tokenDistributionUUID != tokenDistributionUUID) {
            revert WrongTokenDistribution(claimData.tokenDistributionUUID, tokenDistributionUUID);
        }

        if (block.timestamp >= claimData.expiresAt) {
            revert ClaimExpired(claimData.expiresAt);
        }

        {
            bytes32 leaf = Merkle.hashLeaf(abi.encode(user));
            bytes32 computedRoot = MerkleProof.processProofCalldata(merkleProof, leaf);
            if (computedRoot != claimersRoot) {
                revert InvalidClaimerMerkleProof(leaf, computedRoot, claimersRoot);
            }
        }

        {
            bytes32 digest = ClaimDataLib.digestTypedData(claimData, _domainSeparatorV4());

            if (
                !isForcedDistributionModeEnabled
                    && !SignatureChecker.isValidSignatureNow(user.signer, digest, claimSignatureUser)
            ) {
                address signer = ECDSA.recover(digest, claimSignatureUser);
                revert UnauthorizedUserSigner(signer, user.signer);
            }

            address signerPlatform = ECDSA.recover(digest, claimSignaturePlatform);
            if (!hasRole(SIGNER_ROLE, signerPlatform)) {
                revert UnauthorizedPlatformSigner(signerPlatform);
            }
        }

        ClaimerState storage state = _claimerState[claimData.entityUUID];

        {
            // we don't include the releasable amount here and only consider the actual amount received by the contract
            uint256 claimableAmount = _claimable(claimData.entityUUID, user.distributionShares, false);
            if (claimData.amount > claimableAmount) {
                revert AmountExceedsClaimable(claimData.amount, claimableAmount);
            }
        }

        uint256 amountUSDC = claimData.price.convertTokenToUSDC(claimData.amount);
        uint256 amountCarry = _calculateCarryAmount(
            claimData.entityUUID, user.amountInvestedUSDC, user.notChargedCarry, claimData.amount, claimData.price
        );

        state.amountClaimed += claimData.amount;
        state.amountClaimedUSDC += uint64(amountUSDC);

        totalClaimed += claimData.amount;
        totalCarryGenerated += amountCarry;

        emit Claimed(
            tokenDistributionUUID, claimData.entityUUID, claimData.receiver, claimData.amount, amountUSDC, amountCarry
        );

        token.safeTransfer(claimData.receiver, claimData.amount - amountCarry);
    }

    function _calculateCarryAmountUSDC(
        uint256 investedUSDC,
        uint256 claimedUSDC,
        uint256 amountToClaimUSDC,
        uint256 totalCarryBPS_
    ) internal pure returns (uint256) {
        uint256 remainingAmountFreeOfCarryUSDC = investedUSDC > claimedUSDC ? investedUSDC - claimedUSDC : 0;
        uint256 amountWithCarryUSDC =
            amountToClaimUSDC > remainingAmountFreeOfCarryUSDC ? amountToClaimUSDC - remainingAmountFreeOfCarryUSDC : 0;
        return Math.mulDiv(amountWithCarryUSDC, totalCarryBPS_, 10000);
    }

    /// @notice Helper function to compute the carry amount for a given claim.
    /// @dev The function does not verify that the amount can actually be claimed by the entity.
    function _calculateCarryAmount(
        bytes16 entityUUID,
        uint256 amountInvestedUSDC,
        bool notChargedCarry,
        uint256 amountToClaim,
        Price calldata price
    ) internal view returns (uint256) {
        if (notChargedCarry) {
            return 0;
        }

        uint256 amountUSDC = price.convertTokenToUSDC(amountToClaim);
        uint256 amountCarryUSDC = _calculateCarryAmountUSDC(
            amountInvestedUSDC, _claimerState[entityUUID].amountClaimedUSDC, amountUSDC, totalCarryBPS
        );
        uint256 amountCarry = price.convertUSDCToToken(amountCarryUSDC);

        return amountCarry;
    }

    /// @notice Withdraws the carry for a given carry receiver (e.g. a deal lead)
    /// @dev This function should only be used for entities and not for the platform. The platform should use the `withdrawCarryPlatform`
    /// The function needs two valid signatures of the claim data (user + platform) to authorize a claim.
    /// There is no additional access control on the function, which allows anyone to execute a claim as long as the signatures are valid.
    /// We chose this approach as it gives us ultimate flexibility in who executes the transaction,
    /// e.g. it could either be send by the user on the frontend or by the platform backend.
    /// Does not require claimer signature if the contract has the`forcedDistributionModeEnabled` flag enabled.
    /// @param data The data required to withdraw the carry
    /// @param userSignature The signature of the user using EIP-712
    /// @param platformSignature The signature of the platform using EIP-712
    function withdrawCarry(
        CarryWithdrawalData calldata data,
        bytes calldata userSignature,
        bytes calldata platformSignature
    ) external onlyIf(isEnabled) {
        if (data.tokenDistributionUUID != tokenDistributionUUID) {
            revert WrongTokenDistribution(data.tokenDistributionUUID, tokenDistributionUUID);
        }

        if (block.timestamp >= data.expiresAt) {
            revert ClaimExpired(data.expiresAt);
        }

        CarryWithdrawerWithoutUUID memory user = _carryWithdrawers[data.entityUUID];
        if (user.signer == address(0)) {
            revert UnknownUser();
        }

        {
            bytes32 digest = CarryWithdrawalLib.digestTypedData(data, _domainSeparatorV4());

            if (
                !isForcedDistributionModeEnabled
                    && !SignatureChecker.isValidSignatureNow(user.signer, digest, userSignature)
            ) {
                address signer = ECDSA.recover(digest, userSignature);
                revert UnauthorizedUserSigner(signer, user.signer);
            }

            address signerPlatform = ECDSA.recover(digest, platformSignature);
            if (!hasRole(SIGNER_ROLE, signerPlatform)) {
                revert UnauthorizedPlatformSigner(signerPlatform);
            }
        }

        {
            uint256 maxAmount = _carryWithdrawable(data.entityUUID, user.carryBPS);
            if (data.amount > maxAmount) {
                revert AmountExceedsWithdrawableCarry(data.amount, maxAmount);
            }
        }

        _carryAmountWithdrawn[data.entityUUID] += data.amount;
        totalCarryWithdrawn += data.amount;

        emit CarryWithdrawn(data.tokenDistributionUUID, data.entityUUID, data.receiver, data.amount);

        token.safeTransfer(data.receiver, data.amount);
    }

    /// @notice Withdraws the platform carry from the contract.
    /// @dev Carry receivers should use the `withdrawCarry` function.
    /// @param amount The amount of carry in tokens to withdraw
    function withdrawCarryPlatform(uint256 amount) external onlyRole(PLATFORM_CARRY_WITHDRAWER_ROLE) {
        address platformReceiver = genericRegistry.readAddress(GenericRegistryKeys.PLATFORM_CARRY_RECEIVER);
        uint256 maxAmount = _carryWithdrawable(PLATFORM_ENTITY_UUID, platformCarryBPS);
        if (amount > maxAmount) {
            revert AmountExceedsWithdrawableCarry(amount, maxAmount);
        }

        _carryAmountWithdrawn[PLATFORM_ENTITY_UUID] += amount;
        totalCarryWithdrawn += amount;

        emit CarryWithdrawn(tokenDistributionUUID, PLATFORM_ENTITY_UUID, platformReceiver, amount);

        token.safeTransfer(platformReceiver, amount);
    }

    function _carryWithdrawable(bytes16 entityUUID, uint16 carryBPS) internal view returns (uint256) {
        return Math.mulDiv(totalCarryGenerated, carryBPS, totalCarryBPS) - _carryAmountWithdrawn[entityUUID];
    }

    /// @notice Computes the withdrawable carry amount for the platform.
    /// @return The carry withdrawable amount of tokens for the platform.
    function carryWithdrawablePlatform() external view returns (uint256) {
        return _carryWithdrawable(PLATFORM_ENTITY_UUID, platformCarryBPS);
    }

    /// @notice Returns the amount of tokens that have been withdrawn from the carry pool for the platform.
    /// @return The amount of tokens that have been withdrawn from the carry pool for the platform.
    function carryWithdrawnPlatform() external view returns (uint256) {
        return _carryAmountWithdrawn[PLATFORM_ENTITY_UUID];
    }

    /// @notice Computes the carry withdrawable amount for a list of entities.
    /// @dev Not used to calculate the carry withdrawn for the platform as this is handled separately by the platform specific function
    /// `carryWithdrawblePlatform`.
    /// @param entityUUIDs The UUIDs of the entities.
    /// @return The carry withdrawable amount of tokens for each entity.
    function carryWithdrawable(bytes16[] calldata entityUUIDs) external view returns (uint256[] memory) {
        uint256[] memory ret = new uint256[](entityUUIDs.length);
        for (uint256 i = 0; i < entityUUIDs.length; i++) {
            ret[i] = _carryWithdrawable(entityUUIDs[i], _carryWithdrawers[entityUUIDs[i]].carryBPS);
        }
        return ret;
    }

    /// @notice Returns the amount of tokens that have been withdrawn from the carry pool for each entity.
    /// @dev Not used to calculate the carry withdrawn for the platform as this is handled separately by the platform specific function
    /// `carryWithdrawnPlatform`.
    /// @param entityUUIDs The UUIDs of the entities.
    /// @return The amount of tokens that have been withdrawn from the carry pool for each entity.
    function carryWithdrawn(bytes16[] calldata entityUUIDs) external view returns (uint256[] memory) {
        uint256[] memory ret = new uint256[](entityUUIDs.length);
        for (uint256 i = 0; i < entityUUIDs.length; i++) {
            ret[i] = _carryAmountWithdrawn[entityUUIDs[i]];
        }
        return ret;
    }

    function _claimable(bytes16 entityUUID, uint64 distributionShares, bool includeReleasable)
        internal
        view
        returns (uint256)
    {
        // we're using the current balance here instead of keeping track of the amount that was pulled in from the unlock wallet
        // to account for any tokens that were manually sent to the distributor contract

        // the total received amount is computed as the current balance + everything that left the contract
        uint256 totalReceived =
            token.balanceOf(address(this)) + (totalClaimed - totalCarryGenerated) + totalCarryWithdrawn;

        if (includeReleasable) {
            totalReceived += UnlockerLib.releasable(unlocker);
        }

        uint256 unlockedForUser = Math.mulDiv(totalReceived, distributionShares, totalDistributionShares);
        uint256 alreadyClaimed = _claimerState[entityUUID].amountClaimed;

        // We have a bounds check in case there is a discrepancy between what has been prefilled for the claim data
        // and what the user can now claim. This can happen if there was an incorrect amount of tokens that were initially
        // claimed by the user, and we have updated what the user can now claim.
        if (unlockedForUser < alreadyClaimed) {
            return 0;
        }

        return unlockedForUser - alreadyClaimed;
    }

    /// @notice Computes the claimable amount of tokens for a list of users.
    /// @dev The correctness of the response depends on the correctness of the input parameters,
    /// i.e. whether the user UUIDs and invested amounts are included in the settings as encoded in the corresponding merkle root.
    /// The validity of the passed parameters is NOT validated against the stored merkle root.
    /// @param entityUUIDs The UUIDs of the users.
    /// @param distributionShares The amount of SPV shares for each user.
    /// @param includeReleasable Whether to include the amount releasable from the unlocker in the computation.
    function claimable(bytes16[] calldata entityUUIDs, uint64[] calldata distributionShares, bool includeReleasable)
        external
        view
        returns (uint256[] memory)
    {
        uint256[] memory ret = new uint256[](entityUUIDs.length);
        for (uint256 i = 0; i < entityUUIDs.length; i++) {
            ret[i] = _claimable(entityUUIDs[i], distributionShares[i], includeReleasable);
        }
        return ret;
    }

    struct CalculateCarryAmountClaimParameters {
        bytes16 entityUUID;
        uint64 amountInvestedUSDC;
        bool notChargedCarry;
        uint256 amountToClaim;
    }

    /// @notice Computes the carry amounts for a list of claims.
    /// @dev This function is intended to be used offchain to compute the carry amounts for a list of claims.
    /// @dev The correctness of the response depends on the correctness of the input parameters,
    /// i.e. whether the entity UUIDs and investment amounts are included in the settings as encoded in the corresponding merkle root.
    /// The validity of the passed parameters is NOT validated against the stored merkle root.
    /// @dev The function does not verify that the amounts can actually be claimed by the entities.
    function calculateCarryAmountForClaims(
        CalculateCarryAmountClaimParameters[] calldata claimParams,
        Price calldata price
    ) external view returns (uint256[] memory) {
        uint256[] memory carryAmounts = new uint256[](claimParams.length);
        for (uint256 i = 0; i < claimParams.length; i++) {
            carryAmounts[i] = _calculateCarryAmount(
                claimParams[i].entityUUID,
                claimParams[i].amountInvestedUSDC,
                claimParams[i].notChargedCarry,
                claimParams[i].amountToClaim,
                price
            );
        }

        return carryAmounts;
    }

    /// @notice Setter for the generic registry.
    function setGenericRegistry(IGenericRegistry registry) external onlyRole(MANAGER_ROLE) {
        genericRegistry = registry;
    }

    /// @notice Setter for the platform carry BPS
    /// @dev We use a separate setter for the platform carry over setting it in the setCarryWithdrawerSettings
    /// as the platform is separate from a carry receiver.
    /// @param bps The platform's carry in basis points.
    function setPlatformCarryBPS(uint16 bps) external onlyRole(MANAGER_ROLE) {
        if (bps > 2000) {
            revert InvalidConfiguration("Platform carry BPS cannot be greater than 20%");
        }

        totalCarryBPS = totalCarryBPS - platformCarryBPS + bps;
        platformCarryBPS = bps;
    }

    /// @notice Updates the claimers of the distributor.
    /// @dev The function must be used with UTMOST CAUTION since it can change the user's and total amount invested, which will interfere with the claimable amount computation.
    /// @param claimers The claimer settings to update.
    /// @param expectedRoot The expected root of the user settings merkle tree.
    function setClaimers(Claimer[] calldata claimers, bytes32 expectedRoot) external onlyRole(MANAGER_ROLE) {
        _setClaimers(claimers, expectedRoot);
        // TODO add ConfigChanged event
    }

    /// @notice Internal function to set the user settings.
    /// @dev The merkle tree root of the settings is computed and compared against the expected root.
    /// This is intended as a sanity check to make sure we can correctly compute the merkle tree root on the backend.
    function _setClaimers(Claimer[] memory claimers, bytes32 expectedRoot) internal {
        uint64 totalDistributionShares_ = 0;
        bytes32[] memory claimerLeaves = new bytes32[](claimers.length);
        for (uint256 i = 0; i < claimers.length; i++) {
            Claimer memory s = claimers[i];

            if (s.entityUUID == PLATFORM_ENTITY_UUID) {
                revert InvalidConfiguration("entityUUID cannot be the platform entityUUID");
            }

            if (s.signer == address(0)) {
                revert InvalidConfiguration("signer is zero");
            }

            if (s.amountInvestedUSDC == 0) {
                revert InvalidConfiguration("amount invested is zero");
            }

            if (s.distributionShares == 0) {
                revert InvalidConfiguration("distributionShares is zero");
            }

            // TODO check dupes somehow?

            totalDistributionShares_ += s.distributionShares;
            claimerLeaves[i] = Merkle.hashLeaf(abi.encode(s));
            // TODO add some guard rails (input expected totals), sanity checks, etc
        }
        totalDistributionShares = totalDistributionShares_;

        bytes32 computedRoot = Merkle.computeRootInPlace(claimerLeaves);
        if (computedRoot != expectedRoot) {
            revert UnexpectedClaimerMerkleRoot(claimerLeaves, computedRoot, expectedRoot);
        }
        claimersRoot = computedRoot;
    }

    /// @notice Updates the carry withdrawer settings.
    /// @dev This function must be used with UTMOST CAUTION since it can change the carry withdrawable amount, which will interfere with the carryWithdrawable computation.
    /// @param settings The carry withdrawer settings to update.
    function setCarryWithdrawerSettings(CarryWithdrawer[] calldata settings) external onlyRole(MANAGER_ROLE) {
        _setCarryWithdrawerSettings(settings);
        // TODO add ConfigChanged event?
    }

    /// @notice Internal function to set the carry withdrawer settings.
    /// @dev The merkle tree root of the settings is computed and compared against the expected root.
    /// This is intended as a sanity check to make sure we can correctly compute the merkle tree root on the backend.
    function _setCarryWithdrawerSettings(CarryWithdrawer[] memory settings) internal {
        // clearing the existing carry receivers first
        uint256 numExisting = _carryWithdrawerUUIDs.length;
        if (numExisting > 0) {
            for (uint256 i = 0; i < numExisting; i++) {
                delete _carryWithdrawers[_carryWithdrawerUUIDs[i]];
            }
            delete _carryWithdrawerUUIDs;
        }

        uint16 totalCarryBPS_ = 0;
        for (uint256 i = 0; i < settings.length; i++) {
            CarryWithdrawer memory s = settings[i];

            if (s.entityUUID == PLATFORM_ENTITY_UUID) {
                revert InvalidConfiguration("entityUUID cannot be the platform entityUUID");
            }

            if (s.signer == address(0)) {
                revert InvalidConfiguration("signer is zero");
            }

            if (s.carryBPS == 0) {
                revert InvalidConfiguration("carry BPS is zero");
            }

            if (_carryWithdrawers[s.entityUUID].signer != address(0)) {
                revert InvalidConfiguration("entityUUID already exists");
            }

            totalCarryBPS_ += s.carryBPS;
            _carryWithdrawerUUIDs.push(s.entityUUID);
            _carryWithdrawers[s.entityUUID] = CarryWithdrawerWithoutUUID({signer: s.signer, carryBPS: s.carryBPS});
            // TODO add some guard rails (input expected totals), sanity checks, etc
        }
        totalCarryBPS = totalCarryBPS_ + platformCarryBPS;
    }

    function setUnlocker(UnlockerLib.Unlocker calldata unlocker_) external onlyRole(ENG_MANAGER_ROLE) {
        UnlockerLib.validate(unlocker_);
        unlocker = unlocker_;
        emit ConfigChanged(this.setUnlocker.selector, "setUnlocker((address,bytes6,bytes6))", abi.encode(unlocker_));
    }

    function setForcedDistributionModeEnabled(bool enabled) external onlyRole(MANAGER_ROLE) {
        isForcedDistributionModeEnabled = enabled;
    }

    /// @notice Allows the manager to recover any tokens sent to the contract.
    /// @dev This is intended as a safeguard and should only be used in emergencies and with utmost care.
    function recoverTokens(IERC20 coin, address to, uint256 amount) external onlyRole(MANAGER_ROLE) {
        coin.safeTransfer(to, amount);
    }

    function carryWithdrawerUUIDs() external view returns (bytes16[] memory) {
        return _carryWithdrawerUUIDs;
    }

    function carryWithdrawer(bytes16[] calldata entityUUIDs)
        external
        view
        returns (CarryWithdrawerWithoutUUID[] memory)
    {
        CarryWithdrawerWithoutUUID[] memory ret = new CarryWithdrawerWithoutUUID[](entityUUIDs.length);
        for (uint256 i = 0; i < entityUUIDs.length; i++) {
            ret[i] = _carryWithdrawers[entityUUIDs[i]];
        }
        return ret;
    }

    /// @notice Sets whether token claims and carry withdrawals are enabled.
    function _setEnabled(bool isEnabled_) internal {
        isEnabled = isEnabled_;
        emit ConfigChanged(this.setEnabled.selector, "setEnabled(bool)", abi.encode(isEnabled_));
    }

    /// @notice Sets whether the deal funding is enabled.
    function setEnabled(bool isEnabled_) external onlyRole(ENG_MANAGER_ROLE) {
        _setEnabled(isEnabled_);
    }

    /// @notice Pauses the deal funding.
    /// @dev Equivalent to `setEnabled(false)`.
    function pause() external onlyRole(PAUSER_ROLE) {
        _setEnabled(false);
    }

    /// @notice Ensures that a function can only be called if a given flag is true.
    modifier onlyIf(bool flag) {
        if (!flag) {
            revert Disabled();
        }
        _;
    }

    /// @notice The state data for a claimer.
    /// @dev This is used to prefill the distributor with the claimer data from another distributor contract, usually due to the migration from another chain.
    struct PrefillDataClaimerState {
        bytes16 entityUUID;
        ClaimerState state;
    }

    /// @notice Sets the state of claimers in the distributor to the provided data.
    /// @dev This function can be called multiple times in case the prefill needs to be batched due to gas constraints.
    /// @dev Reverts if the state for an entity is already set, which is the case if we pass in the same entity multiple times.
    function prefillClaimerStates(PrefillDataClaimerState[] calldata states) external onlyRole(PREFILL_ROLE) {
        uint256 totalClaimed_ = totalClaimed;
        for (uint256 i = 0; i < states.length; i++) {
            bytes16 entityUUID = states[i].entityUUID;
            ClaimerState calldata state = states[i].state;

            // sanity check that both fields are either both zero or both non-zero
            // we never expect a user to have claimed tokens with zero price
            if ((state.amountClaimed > 0) != (state.amountClaimedUSDC > 0)) {
                revert InvalidClaimerState(entityUUID);
            }

            if (_claimerState[entityUUID].amountClaimed > 0) {
                revert ClaimerStateAlreadySet(entityUUID);
            }

            _claimerState[entityUUID] = state;
            totalClaimed_ += state.amountClaimed;
        }

        totalClaimed = totalClaimed_;
    }

    /// @notice The state data for a carry withdrawer.
    /// @dev This is used to prefill the distributor with the carry withdrawer data from another distributor contract, usually due to the migration from another chain.
    struct PrefillDataWithdrawerState {
        bytes16 entityUUID;
        uint256 amountCarryWithdrawn;
    }

    /// @notice Sets the state of withdrawers in the distributor to the provided data.
    /// @dev This function can be called multiple times in case the prefill needs to be batched due to gas constraints.
    /// @dev Reverts if the state for an entity is already set, which can be the case if we pass in the same entity multiple times.
    function prefillWithdrawerStates(PrefillDataWithdrawerState[] calldata states) external onlyRole(PREFILL_ROLE) {
        uint256 totalCarryWithdrawn_ = totalCarryWithdrawn;
        for (uint256 i = 0; i < states.length; i++) {
            bytes16 entityUUID = states[i].entityUUID;
            if (_carryAmountWithdrawn[entityUUID] > 0) {
                revert WithdrawerStateAlreadySet(entityUUID);
            }

            _carryAmountWithdrawn[entityUUID] = states[i].amountCarryWithdrawn;
            totalCarryWithdrawn_ += states[i].amountCarryWithdrawn;
        }

        totalCarryWithdrawn = totalCarryWithdrawn_;
    }

    /// @notice Finalizes the prefill by setting the totalCarryGenerated and checking expected sums from the prefill data.
    /// @dev The caller renounces the PREFILL_ROLE in this function call, marking the prefill as complete.
    function finalizePrefill(
        uint256 totalCarryGenerated_,
        uint256 expectedTotalClaimed_,
        uint256 expectedTotalCarryWithdrawn_
    ) external onlyRole(PREFILL_ROLE) {
        // we can unfortunately not compute this from other prefilled data, so we pass it in here and set it.
        totalCarryGenerated = totalCarryGenerated_;

        // additional sanity checks that the prefill went as expected
        if (totalClaimed != expectedTotalClaimed_) {
            revert InvalidPrefillExpectedValue("totalClaimed", totalClaimed, expectedTotalClaimed_);
        }

        if (totalCarryWithdrawn != expectedTotalCarryWithdrawn_) {
            revert InvalidPrefillExpectedValue("totalCarryWithdrawn", totalCarryWithdrawn, expectedTotalCarryWithdrawn_);
        }

        renounceRole(PREFILL_ROLE, msg.sender);
    }
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

import {TransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {Distributor} from "./Distributor.sol";

function newDistributor(address admin, Distributor impl, Distributor.Init memory init) returns (Distributor) {
    TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(
        address(impl), admin, abi.encodeWithSelector(Distributor.initialize.selector, init)
    );
    return Distributor(payable(address(proxy)));
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

/// @notice Interface for Echo Unlocker contracts.
interface IEchoUnlocker {
    function releasable() external view returns (uint256);
    function release() external;
}

/// @notice Interface for Superfluid Unlocker contracts (SuperfluidToken).
/// @dev The unlocker address for Superfluid should be the SuperToken address.
interface ISuperfluidUnlocker {
    function balanceOf(address account) external view returns (uint256);
    function downgrade(uint256 amount) external;
}

/// @notice Library for managing calls to unlocker contracts.
/// @dev The distributor contracts will need to interface with a number of different unlocker contracts.
/// This library provides a dynamic function dispatch to make interacting with Unlocker contracts easier.
library UnlockerLib {
    /// @notice Struct for holding the unlocker contract address and the function types it implements.
    /// @dev This is used to dynamically dispatch calls to the correct function on the unlocker contract as specified by the releasableType and releaseType.
    /// @dev The unlocker address may be 0, in which case no function calls will be made.
    struct Unlocker {
        address unlocker;
        bytes6 releasableType;
        bytes6 releaseType;
    }

    /// Below we list identifiers for functions that might be implemented by unlocker contracts.
    /// EXISTING TYPE MUST NOT BE CHANGED!
    /// If you append new types, make sure to also update the ones in `/backend/lib/contracts/contracts/unlock/types/types.go`
    bytes6 constant NO_TYPE = bytes6(0);
    bytes6 constant ECHO_TYPE = bytes6(keccak256("ECHO"));
    bytes6 constant SUPERFLUID_TYPE = bytes6(keccak256("SUPERFLUID"));

    error InvalidFunctionType(bytes6);
    error InvalidUnlocker(string reason);

    /// @notice Event emitted when the release function on the unlocker contract reverts but we chose to ignore the revert.
    event ReleaseFailedLog(bytes reason);

    /// @notice Returns the amount of tokens that are releasable from the unlocker contract.
    /// @dev This function calls the releasable function on the unlocker contract as specified by the releasableType.
    /// @dev This function does nothing if the unlocker contract address is not set.
    function releasable(Unlocker memory unlocker) internal view returns (uint256) {
        // there is nothing to release if the unlocker is not set
        if (unlocker.unlocker == address(0)) {
            return 0;
        }

        if (unlocker.releasableType == ECHO_TYPE) {
            return IEchoUnlocker(unlocker.unlocker).releasable();
        }

        if (unlocker.releasableType == SUPERFLUID_TYPE) {
            return ISuperfluidUnlocker(unlocker.unlocker).balanceOf(address(this));
        }

        revert InvalidFunctionType(unlocker.releasableType);
    }

    /// @notice Releases the tokens from the unlocker contract.
    /// @dev This function calls the release function on the unlocker contract as specified by the releaseType.
    /// @dev This function will catch any reverts from the release function and emit a log.
    /// @dev This function does nothing if the unlocker contract address is not set.
    function release(Unlocker memory unlocker) internal {
        // there is nothing to release if the unlocker is not set
        // the distributor is receive only in this case
        if (unlocker.unlocker == address(0)) {
            return;
        }

        if (unlocker.releaseType == ECHO_TYPE) {
            try IEchoUnlocker(unlocker.unlocker).release() {}
            catch (bytes memory reason) {
                // emitting a log for easier debugging
                emit ReleaseFailedLog(reason);
            }
            return;
        }

        if (unlocker.releaseType == SUPERFLUID_TYPE) {
            try ISuperfluidUnlocker(unlocker.unlocker).downgrade(
                ISuperfluidUnlocker(unlocker.unlocker).balanceOf(address(this))
            ) {} catch (bytes memory reason) {
                emit ReleaseFailedLog(reason);
            }
            return;
        }

        revert InvalidFunctionType(unlocker.releaseType);
    }

    /// @notice Validates the unlocker struct.
    function validate(Unlocker memory unlocker) internal pure {
        if (unlocker.unlocker == address(0)) {
            if (unlocker.releasableType != NO_TYPE || unlocker.releaseType != NO_TYPE) {
                revert InvalidUnlocker("unlocker is unset but function types are set");
            }
            return;
        }

        if (unlocker.releasableType != ECHO_TYPE && unlocker.releasableType != SUPERFLUID_TYPE) {
            revert InvalidFunctionType(unlocker.releasableType);
        }

        if (unlocker.releaseType != ECHO_TYPE && unlocker.releaseType != SUPERFLUID_TYPE) {
            revert InvalidFunctionType(unlocker.releaseType);
        }
    }
}

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

/// @notice USDC pricing data for a token.
/// @dev The amount of USDC for a given amount of tokens is computed by `amountUSDCUnits = (amountTokenUnits * tokenPriceUSDCNumerator) / tokenPriceUSDCDenominator`.
/// e.g. assuming a 18 decimals for the token, and 6 decimals for usdc,
/// an exchange rate of 1 token = 1234.5678 USDC would mean 1e18 tokenUnits = 1,234,567,800 USDCUnits, corresponding to tokenPriceUSDCNumerator = 1234567800 and tokenPriceUSDCDenominator = 1e18.
/// @param tokenPriceUSDCNumerator The numerator of the token unit price in USDC units.
/// @param tokenPriceUSDCDenominator The denominator of the token unit price in USDC units.
struct Price {
    uint256 tokenPriceUSDCNumerator;
    uint256 tokenPriceUSDCDenominator;
}

library PriceLib {
    function convertTokenToUSDC(Price memory data, uint256 amount) internal pure returns (uint256) {
        return Math.mulDiv(amount, data.tokenPriceUSDCNumerator, data.tokenPriceUSDCDenominator);
    }

    function convertUSDCToToken(Price memory data, uint256 usdcAmount) internal pure returns (uint256) {
        return Math.mulDiv(usdcAmount, data.tokenPriceUSDCDenominator, data.tokenPriceUSDCNumerator);
    }
}

struct ClaimData {
    bytes16 tokenDistributionUUID;
    bytes16 entityUUID;
    address receiver;
    uint256 amount;
    Price price;
    uint256 expiresAt;
}

library ClaimDataLib {
    /// @notice EIP-712 typehash for the ClaimData struct.
    bytes32 constant CLAIM_TYPEHASH = keccak256(
        "ClaimData(bytes16 tokenDistributionUUID,bytes16 entityUUID,address receiver,uint256 amount,Price price,uint256 expiresAt)Price(uint256 tokenPriceUSDCNumerator,uint256 tokenPriceUSDCDenominator)"
    );

    /// @notice EIP-712 typehash for the Price struct.
    bytes32 constant PRICE_TYPEHASH =
        keccak256("Price(uint256 tokenPriceUSDCNumerator,uint256 tokenPriceUSDCDenominator)");

    /// @notice Computes the typed data digest of a ClaimData for a given domain separator.
    function digestTypedData(ClaimData memory data, bytes32 domainSeparator) internal pure returns (bytes32) {
        bytes32 priceHash = keccak256(
            abi.encode(PRICE_TYPEHASH, data.price.tokenPriceUSDCNumerator, data.price.tokenPriceUSDCDenominator)
        );

        bytes32 structHash = keccak256(
            abi.encode(
                CLAIM_TYPEHASH,
                data.tokenDistributionUUID,
                data.entityUUID,
                data.receiver,
                data.amount,
                priceHash,
                data.expiresAt
            )
        );

        return MessageHashUtils.toTypedDataHash(domainSeparator, structHash);
    }
}

struct Claimer {
    bytes16 entityUUID;
    address signer;
    uint64 amountInvestedUSDC;
    uint64 distributionShares;
    bool notChargedCarry;
}

struct CarryWithdrawer {
    bytes16 entityUUID;
    address signer;
    uint16 carryBPS;
}

struct CarryWithdrawalData {
    bytes16 tokenDistributionUUID;
    bytes16 entityUUID;
    address receiver;
    uint256 amount;
    uint256 expiresAt;
}

library CarryWithdrawalLib {
    /// @notice EIP-712 typehash for the CarryWithdrawalData struct.
    bytes32 constant CARRY_WITHDRAWAL_DATA_TYPEHASH = keccak256(
        "CarryWithdrawalData(bytes16 tokenDistributionUUID,bytes16 entityUUID,address receiver,uint256 amount,uint256 expiresAt)"
    );

    /// @notice Computes the typed data digest of a CarryWithdrawalData for a given domain separator.
    function digestTypedData(CarryWithdrawalData memory data, bytes32 domainSeparator)
        internal
        pure
        returns (bytes32)
    {
        bytes32 structHash = keccak256(
            abi.encode(
                CARRY_WITHDRAWAL_DATA_TYPEHASH,
                data.tokenDistributionUUID,
                data.entityUUID,
                data.receiver,
                data.amount,
                data.expiresAt
            )
        );

        return MessageHashUtils.toTypedDataHash(domainSeparator, structHash);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/IAccessControlEnumerable.sol)

pragma solidity ^0.8.20;

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

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

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

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

        _revokeRole(role, callerConfirmation);
    }

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position is the index of the value in the `values` array plus 1.
        // Position 0 is used to mean a value is not in the set.
        mapping(bytes32 value => uint256) _positions;
    }

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

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

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

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

            if (valueIndex != lastIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the lastValue to the index where the value to delete is
                set._values[valueIndex] = lastValue;
                // Update the tracked position of the lastValue (that was just moved)
                set._positions[lastValue] = position;
            }

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

            // Delete the tracked position for the deleted slot
            delete set._positions[value];

            return true;
        } else {
            return false;
        }
    }

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../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;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

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

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

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

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

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

    /**
     * @dev 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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.20;

import {ECDSA} from "./ECDSA.sol";
import {IERC1271} from "../../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 Safe Wallet (previously Gnosis Safe).
 */
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);
        return
            (error == ECDSA.RecoverError.NoError && recovered == signer) ||
            isValidERC1271SignatureNow(signer, hash, signature);
    }

    /**
     * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated
     * against the signer smart contract using ERC1271.
     *
     * 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 isValidERC1271SignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeCall(IERC1271.isValidSignature, (hash, signature))
        );
        return (success &&
            result.length >= 32 &&
            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.20;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the Merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates Merkle trees that are safe
 * against this attack out of the box.
 */
library MerkleProof {
    /**
     *@dev The multiproof provided is not valid.
     */
    error MerkleProofInvalidMultiproof();

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     */
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proofLen != totalHashes + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            if (proofPos != proofLen) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofLen = proof.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proofLen != totalHashes + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            if (proofPos != proofLen) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[totalHashes - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Sorts the pair (a, b) and hashes the result.
     */
    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    /**
     * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
     */
    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlEnumerable.sol)

pragma solidity ^0.8.20;

import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol";
import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerable, AccessControlUpgradeable {
    using EnumerableSet for EnumerableSet.AddressSet;

    /// @custom:storage-location erc7201:openzeppelin.storage.AccessControlEnumerable
    struct AccessControlEnumerableStorage {
        mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlEnumerable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessControlEnumerableStorageLocation = 0xc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000;

    function _getAccessControlEnumerableStorage() private pure returns (AccessControlEnumerableStorage storage $) {
        assembly {
            $.slot := AccessControlEnumerableStorageLocation
        }
    }

    function __AccessControlEnumerable_init() internal onlyInitializing {
    }

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

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

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

    /**
     * @dev Overload {AccessControl-_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
        AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
        bool granted = super._grantRole(role, account);
        if (granted) {
            $._roleMembers[role].add(account);
        }
        return granted;
    }

    /**
     * @dev Overload {AccessControl-_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
        AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
        bool revoked = super._revokeRole(role, account);
        if (revoked) {
            $._roleMembers[role].remove(account);
        }
        return revoked;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.20;

import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose
 * encoding is very generic and therefore its 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 order to
 * produce the hash of their typed data 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].
 *
 * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
 * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the
 * separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
 */
abstract contract EIP712Upgradeable is Initializable, IERC5267 {
    bytes32 private constant TYPE_HASH =
        keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    /// @custom:storage-location erc7201:openzeppelin.storage.EIP712
    struct EIP712Storage {
        /// @custom:oz-renamed-from _HASHED_NAME
        bytes32 _hashedName;
        /// @custom:oz-renamed-from _HASHED_VERSION
        bytes32 _hashedVersion;

        string _name;
        string _version;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.EIP712")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;

    function _getEIP712Storage() private pure returns (EIP712Storage storage $) {
        assembly {
            $.slot := EIP712StorageLocation
        }
    }

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

    function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
        EIP712Storage storage $ = _getEIP712Storage();
        $._name = name;
        $._version = version;

        // Reset prior values in storage if upgrading
        $._hashedName = 0;
        $._hashedVersion = 0;
    }

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

    function _buildDomainSeparator() private view returns (bytes32) {
        return keccak256(abi.encode(TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), 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 MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev See {IERC-5267}.
     */
    function eip712Domain()
        public
        view
        virtual
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        )
    {
        EIP712Storage storage $ = _getEIP712Storage();
        // If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized
        // and the EIP712 domain is not reliable, as it will be missing name and version.
        require($._hashedName == 0 && $._hashedVersion == 0, "EIP712: Uninitialized");

        return (
            hex"0f", // 01111
            _EIP712Name(),
            _EIP712Version(),
            block.chainid,
            address(this),
            bytes32(0),
            new uint256[](0)
        );
    }

    /**
     * @dev The name parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712Name() internal view virtual returns (string memory) {
        EIP712Storage storage $ = _getEIP712Storage();
        return $._name;
    }

    /**
     * @dev The version parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712Version() internal view virtual returns (string memory) {
        EIP712Storage storage $ = _getEIP712Storage();
        return $._version;
    }

    /**
     * @dev The hash of the name parameter for the EIP712 domain.
     *
     * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.
     */
    function _EIP712NameHash() internal view returns (bytes32) {
        EIP712Storage storage $ = _getEIP712Storage();
        string memory name = _EIP712Name();
        if (bytes(name).length > 0) {
            return keccak256(bytes(name));
        } else {
            // If the name is empty, the contract may have been upgraded without initializing the new storage.
            // We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.
            bytes32 hashedName = $._hashedName;
            if (hashedName != 0) {
                return hashedName;
            } else {
                return keccak256("");
            }
        }
    }

    /**
     * @dev The hash of the version parameter for the EIP712 domain.
     *
     * NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.
     */
    function _EIP712VersionHash() internal view returns (bytes32) {
        EIP712Storage storage $ = _getEIP712Storage();
        string memory version = _EIP712Version();
        if (bytes(version).length > 0) {
            return keccak256(bytes(version));
        } else {
            // If the version is empty, the contract may have been upgraded without initializing the new storage.
            // We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.
            bytes32 hashedVersion = $._hashedVersion;
            if (hashedVersion != 0) {
                return hashedVersion;
            } else {
                return keccak256("");
            }
        }
    }
}

File 19 of 46 : PlatformEvents.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

/// @notice Emitted when a configuration has been updated.
/// @param setterSelector The selector of the function that updated the configuration.
/// @param setterSignature The signature of the function that updated the configuration.
/// @param value The abi-encoded data passed to the function that updated the configuration. Since this event will only be emitted by setters, this data corresponds to the updated values in the configuration.
event ConfigChanged(bytes4 indexed setterSelector, string setterSignature, bytes value);

// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

/// @notice A library for computing merkle tree roots and proofs.
/// @dev This library produces complete trees. If a node does not have a sibling, it is combined with itself.
library Merkle {
    /// @notice A merkle tree.
    /// @dev Contains the leaf hashes at the 0th level, pairwise hashes in the following, and the root in the last.
    struct Tree {
        bytes32[][] hashes;
    }

    function newTreeFromData(bytes[] memory leaves) internal pure returns (Tree memory tree) {
        bytes32[] memory leafDigests = new bytes32[](leaves.length);
        for (uint256 i; i < leaves.length; i++) {
            leafDigests[i] = hashLeaf(leaves[i]);
        }
        return newTree(leafDigests);
    }

    /// @notice Creates a new merkle tree.
    /// @param leafs The leafs of the tree computed with `hashLeaf`.
    function newTree(bytes32[] memory leafs) internal pure returns (Tree memory tree) {
        if (leafs.length == 0) {
            return Tree({hashes: new bytes32[][](0)});
        }

        uint256 depth = Math.log2(leafs.length);
        // round up to the next power of 2
        if (leafs.length != 1 << depth || leafs.length == 1) {
            depth++;
        }

        // +1 for the leafs
        tree.hashes = new bytes32[][](depth + 1);
        tree.hashes[0] = leafs;

        for (uint256 i; i < depth; ++i) {
            tree.hashes[i + 1] = hashPairs(tree.hashes[i], false);
        }
    }

    /// @notice Hashes the raw data of a leaf.
    /// @dev This uses double keccak256 hashing instead of a single one to prevent second-preimage attacks.
    function hashLeaf(bytes memory data) internal pure returns (bytes32) {
        bytes32 hash = keccak256(data);
        assembly {
            mstore(0x00, hash)
            hash := keccak256(0x00, 0x20)
        }
        return hash;
    }

    /// @notice Returns the root of the merkle tree.
    function root(Tree memory tree) internal pure returns (bytes32) {
        if (tree.hashes.length == 0) {
            return bytes32(0);
        }
        return tree.hashes[tree.hashes.length - 1][0];
    }

    /// @notice Computes a merkle proof compatible with OZ's merkle proof validation.
    function proof(Tree memory tree, uint256 leafIdx) internal pure returns (bytes32[] memory) {
        uint256 len = proofLength(tree);
        bytes32[] memory proof_ = new bytes32[](len);

        for (uint256 i; i < len; ++i) {
            bool odd = (leafIdx % 2) == 1;
            uint256 neighbour = odd ? leafIdx - 1 : leafIdx == tree.hashes[i].length - 1 ? leafIdx : leafIdx + 1;

            proof_[i] = tree.hashes[i][neighbour];

            leafIdx /= 2;
        }
        return proof_;
    }

    function proofLength(Tree memory tree) internal pure returns (uint256) {
        // Minus one because proof don't contain the highest level of the tree
        // (i.e. the merkle root).
        return levels(tree) - 1;
    }

    function levels(Tree memory tree) internal pure returns (uint256) {
        return tree.hashes.length;
    }

    function numLeafs(Tree memory tree) internal pure returns (uint256) {
        return tree.hashes[0].length;
    }

    /// @notice Computes the merkle root of the leaves in place.
    /// @dev Caution! This modifies the input array!
    /// @dev This is more efficient than creating a tree and calling `root` on it.
    function computeRootInPlace(bytes32[] memory leaves) internal pure returns (bytes32) {
        if (leaves.length == 0) {
            return bytes32(0);
        }

        // always hash at least once, for the case where leaves.length == 1
        leaves = hashPairs(leaves, true);
        while (leaves.length > 1) {
            leaves = hashPairs(leaves, true);
        }
        return leaves[0];
    }

    function hashPairs(bytes32[] memory leaves, bool inPlace) internal pure returns (bytes32[] memory) {
        uint256 lenOld = leaves.length;
        uint256 lenNew = lenOld / 2;

        bool odd = lenOld % 2 != 0;
        if (odd) {
            lenNew++;
        }

        bytes32[] memory h = leaves;
        if (!inPlace) {
            h = new bytes32[](lenNew);
        }

        uint256 end = odd ? lenNew - 1 : lenNew;
        for (uint256 i; i < end; ++i) {
            h[i] = hashPair(leaves[2 * i], leaves[2 * i + 1]);
        }

        if (odd) {
            h[lenNew - 1] = hashPair(leaves[lenOld - 1], leaves[lenOld - 1]);
        }

        if (inPlace) {
            assembly {
                mstore(h, lenNew)
            }
        }

        return h;
    }

    function hashPair(bytes32 a, bytes32 b) internal pure returns (bytes32) {
        return a < b ? efficientHash(a, b) : efficientHash(b, a);
    }

    function efficientHash(bytes32 a, bytes32 b) internal pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 21 of 46 : GenericRegistryKeys.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.23;

library GenericRegistryKeys {
    bytes32 constant PLATFORM_CARRY_RECEIVER = keccak256("PLATFORM_CARRY_RECEIVER");
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/transparent/TransparentUpgradeableProxy.sol)

pragma solidity ^0.8.20;

import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
import {ERC1967Proxy} from "../ERC1967/ERC1967Proxy.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {ProxyAdmin} from "./ProxyAdmin.sol";

/**
 * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}
 * does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch
 * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not
 * include them in the ABI so this interface must be used to interact with it.
 */
interface ITransparentUpgradeableProxy is IERC1967 {
    function upgradeToAndCall(address, bytes calldata) external payable;
}

/**
 * @dev This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance.
 *
 * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
 * clashing], which can potentially be used in an attack, this contract uses the
 * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
 * things that go hand in hand:
 *
 * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
 * that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself.
 * 2. If the admin calls the proxy, it can call the `upgradeToAndCall` function but any other call won't be forwarded to
 * the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating
 * the proxy admin cannot fallback to the target implementation.
 *
 * These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a
 * dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to
 * call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and
 * allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative
 * interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership.
 *
 * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
 * inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch
 * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
 * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
 * implementation.
 *
 * NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a
 * meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract.
 *
 * IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an
 * immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be
 * overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an
 * undesirable state where the admin slot is different from the actual admin.
 *
 * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the
 * compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new
 * function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This
 * could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency.
 */
contract TransparentUpgradeableProxy is ERC1967Proxy {
    // An immutable address for the admin to avoid unnecessary SLOADs before each call
    // at the expense of removing the ability to change the admin once it's set.
    // This is acceptable if the admin is always a ProxyAdmin instance or similar contract
    // with its own ability to transfer the permissions to another account.
    address private immutable _admin;

    /**
     * @dev The proxy caller is the current admin, and can't fallback to the proxy target.
     */
    error ProxyDeniedAdminAccess();

    /**
     * @dev Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`,
     * backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in
     * {ERC1967Proxy-constructor}.
     */
    constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
        _admin = address(new ProxyAdmin(initialOwner));
        // Set the storage value and emit an event for ERC-1967 compatibility
        ERC1967Utils.changeAdmin(_proxyAdmin());
    }

    /**
     * @dev Returns the admin of this proxy.
     */
    function _proxyAdmin() internal virtual returns (address) {
        return _admin;
    }

    /**
     * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
     */
    function _fallback() internal virtual override {
        if (msg.sender == _proxyAdmin()) {
            if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
                revert ProxyDeniedAdminAccess();
            } else {
                _dispatchUpgradeToAndCall();
            }
        } else {
            super._fallback();
        }
    }

    /**
     * @dev Upgrade the implementation of the proxy. See {ERC1967Utils-upgradeToAndCall}.
     *
     * Requirements:
     *
     * - If `data` is empty, `msg.value` must be zero.
     */
    function _dispatchUpgradeToAndCall() private {
        (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
        ERC1967Utils.upgradeToAndCall(newImplementation, data);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/transparent/ProxyAdmin.sol)

pragma solidity ^0.8.20;

import {ITransparentUpgradeableProxy} from "./TransparentUpgradeableProxy.sol";
import {Ownable} from "../../access/Ownable.sol";

/**
 * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
 * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
 */
contract ProxyAdmin is Ownable {
    /**
     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address)`
     * and `upgradeAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
     * while `upgradeAndCall` will invoke the `receive` function if the second argument is the empty byte string.
     * If the getter returns `"5.0.0"`, only `upgradeAndCall(address,bytes)` is present, and the second argument must
     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
     * during an upgrade.
     */
    string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";

    /**
     * @dev Sets the initial owner who can perform upgrades.
     */
    constructor(address initialOwner) Ownable(initialOwner) {}

    /**
     * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation.
     * See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}.
     *
     * Requirements:
     *
     * - This contract must be the admin of `proxy`.
     * - If `data` is empty, `msg.value` must be zero.
     */
    function upgradeAndCall(
        ITransparentUpgradeableProxy proxy,
        address implementation,
        bytes memory data
    ) public payable virtual onlyOwner {
        proxy.upgradeToAndCall{value: msg.value}(implementation, data);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

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

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

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

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

    /**
     * @dev Returns the 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 towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
 *
 * The library provides methods for generating a hash of a message that conforms to the
 * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
 * specifications.
 */
library MessageHashUtils {
    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing a bytes32 `messageHash` with
     * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
     * keccak256, although any bytes32 value can be safely used because the final digest will
     * be re-hashed.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
            mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
            digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
        }
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x45` (`personal_sign` messages).
     *
     * The digest is calculated by prefixing an arbitrary `message` with
     * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
     * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
     *
     * See {ECDSA-recover}.
     */
    function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
        return
            keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-191 signed data with version
     * `0x00` (data with intended validator).
     *
     * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
     * `validator` address. Then hashing the result.
     *
     * See {ECDSA-recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(hex"19_00", validator, data));
    }

    /**
     * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
     *
     * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
     * `\x19\x01` and hashing the result. It corresponds to the hash signed by the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
     *
     * See {ECDSA-recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, hex"19_01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            digest := keccak256(ptr, 0x42)
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.20;

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

    /**
     * @dev The signature derives the `address(0)`.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile 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 {MessageHashUtils-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]
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
        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.
            /// @solidity memory-safe-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 {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM precompile 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 {MessageHashUtils-toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
        _throwError(error, errorArg);
        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]
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            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.
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError, bytes32) {
        // 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, s);
        }

        // 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, bytes32(0));
        }

        return (signer, RecoverError.NoError, bytes32(0));
    }

    /**
     * @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, bytes32 errorArg) = tryRecover(hash, v, r, s);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

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

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

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

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, 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 `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

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

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

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1271.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 */
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);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

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

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

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;


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

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

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

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

    function __AccessControl_init() internal onlyInitializing {
    }

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

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

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

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

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

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

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

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

        _revokeRole(role, callerConfirmation);
    }

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

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

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

File 34 of 46 : IERC5267.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol)

pragma solidity ^0.8.20;

interface IERC5267 {
    /**
     * @dev MAY be emitted to signal that the domain could have changed.
     */
    event EIP712DomainChanged();

    /**
     * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
     * signature.
     */
    function eip712Domain()
        external
        view
        returns (
            bytes1 fields,
            string memory name,
            string memory version,
            uint256 chainId,
            address verifyingContract,
            bytes32 salt,
            uint256[] memory extensions
        );
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 */
library ERC1967Utils {
    // We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
    // This will be fixed in Solidity 0.8.21. At that point we should remove these events.
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Proxy.sol)

pragma solidity ^0.8.20;

import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "./ERC1967Utils.sol";

/**
 * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
 * implementation address that can be changed. This address is stored in storage in the location specified by
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
 * implementation behind the proxy.
 */
contract ERC1967Proxy is Proxy {
    /**
     * @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
     *
     * If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
     * encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
     *
     * Requirements:
     *
     * - If `data` is empty, `msg.value` must be zero.
     */
    constructor(address implementation, bytes memory _data) payable {
        ERC1967Utils.upgradeToAndCall(implementation, _data);
    }

    /**
     * @dev Returns the current implementation address.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
     */
    function _implementation() internal view virtual override returns (address) {
        return ERC1967Utils.getImplementation();
    }
}

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

pragma solidity ^0.8.20;

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

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

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        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_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
     * representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

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

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

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

pragma solidity ^0.8.20;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)

pragma solidity ^0.8.20;

/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback
     * function and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable virtual {
        _fallback();
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

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

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin-4.9.6/contracts/=lib/openzeppelin-contracts-4.9.6/contracts/",
    "@superfluid-finance/ethereum-contracts/contracts/=lib/superfluid-protocol-monorepo/packages/ethereum-contracts/contracts/",
    "@superfluid-finance/solidity-semantic-money/=lib/superfluid-protocol-monorepo/packages/solidity-semantic-money/",
    "ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "echo/=src/",
    "openzeppelin-contracts-4.9.6/=lib/openzeppelin-contracts-4.9.6/contracts/",
    "superfluid-protocol-monorepo/=lib/superfluid-protocol-monorepo/packages/solidity-semantic-money/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "shanghai",
  "viaIR": false,
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"components":[{"internalType":"address","name":"adminIM","type":"address"},{"internalType":"address","name":"adminENG","type":"address"},{"internalType":"address","name":"platform","type":"address"},{"components":[{"internalType":"address","name":"adminIM","type":"address"},{"internalType":"address","name":"managerIM","type":"address"},{"internalType":"address","name":"adminENG","type":"address"},{"internalType":"contract IGenericRegistry","name":"genericRegistry","type":"address"}],"internalType":"struct DistributorFactory.IMFixedDistributorCreationParams","name":"imFixedDistributorCreationParams","type":"tuple"},{"components":[{"internalType":"address","name":"managerENG","type":"address"},{"internalType":"address","name":"platformSigner","type":"address"},{"internalType":"address","name":"platformSender","type":"address"}],"internalType":"struct DistributorFactory.ENGFixedDistributorCreationParams","name":"engFixedDistributorCreationParams","type":"tuple"}],"internalType":"struct DistributorFactory.Init","name":"init","type":"tuple"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes16","name":"tokenDistributionUUID","type":"bytes16"},{"indexed":true,"internalType":"address","name":"distributorAddress","type":"address"}],"name":"DistributorCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ENG_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ENG_MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PLATFORM_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"bytes16","name":"tokenDistributionUUID","type":"bytes16"},{"components":[{"internalType":"address","name":"unlocker","type":"address"},{"internalType":"bytes6","name":"releasableType","type":"bytes6"},{"internalType":"bytes6","name":"releaseType","type":"bytes6"}],"internalType":"struct UnlockerLib.Unlocker","name":"unlocker","type":"tuple"},{"components":[{"internalType":"bytes16","name":"entityUUID","type":"bytes16"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"uint64","name":"amountInvestedUSDC","type":"uint64"},{"internalType":"uint64","name":"distributionShares","type":"uint64"},{"internalType":"bool","name":"notChargedCarry","type":"bool"}],"internalType":"struct Claimer[]","name":"claimers","type":"tuple[]"},{"components":[{"internalType":"bytes16","name":"entityUUID","type":"bytes16"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"uint16","name":"carryBPS","type":"uint16"}],"internalType":"struct CarryWithdrawer[]","name":"carryWithdrawers","type":"tuple[]"},{"internalType":"bytes32","name":"expectedClaimersRoot","type":"bytes32"},{"internalType":"uint16","name":"platformCarryBPS","type":"uint16"}],"internalType":"struct DistributorFactory.VariableDistributorCreationParams","name":"params","type":"tuple"}],"name":"createDistributor","outputs":[{"internalType":"contract Distributor","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distributorImpl","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"engFixedDistributorCreationParams","outputs":[{"internalType":"address","name":"managerENG","type":"address"},{"internalType":"address","name":"platformSigner","type":"address"},{"internalType":"address","name":"platformSender","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"imFixedDistributorCreationParams","outputs":[{"internalType":"address","name":"adminIM","type":"address"},{"internalType":"address","name":"managerIM","type":"address"},{"internalType":"address","name":"adminENG","type":"address"},{"internalType":"contract IGenericRegistry","name":"genericRegistry","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImpl","type":"address"}],"name":"setDistributorImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"managerENG","type":"address"},{"internalType":"address","name":"platformSigner","type":"address"},{"internalType":"address","name":"platformSender","type":"address"}],"internalType":"struct DistributorFactory.ENGFixedDistributorCreationParams","name":"newParams","type":"tuple"}],"name":"setENGFixedDistributorCreationParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"adminIM","type":"address"},{"internalType":"address","name":"managerIM","type":"address"},{"internalType":"address","name":"adminENG","type":"address"},{"internalType":"contract IGenericRegistry","name":"genericRegistry","type":"address"}],"internalType":"struct DistributorFactory.IMFixedDistributorCreationParams","name":"newParams","type":"tuple"}],"name":"setIMFixedDistributorCreationParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"}]

0x60e060405234801562000010575f80fd5b5060405162008722380380620087228339810160408190526200003391620004eb565b60026080525f60a081905260c052620000695f80516020620087028339815191525f80516020620086e283398151915262000251565b620000a37f797343f8d6a29aafeb3aaf0910a8973e0081c60c2f6c1f775cd9f76ea348fc1e5f805160206200870283398151915262000251565b8051620000b2905f906200029b565b508051620000e2907f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08906200029b565b50620001075f80516020620086e283398151915282602001516200029b60201b60201c565b506200012c5f805160206200870283398151915282602001516200029b60201b60201c565b50620001637f797343f8d6a29aafeb3aaf0910a8973e0081c60c2f6c1f775cd9f76ea348fc1e82604001516200029b60201b60201c565b506060818101518051600280546001600160a01b03199081166001600160a01b0393841617909155602080840151600380548416918516919091179055604080850151600480548516918616919091179055939094015160058054831691841691909117905560808501518051600680548416918516919091179055938401516007805483169184169190911790559282015160088054909416911617909155516200020f90620003d8565b604051809103905ff08015801562000229573d5f803e3d5ffd5b50600980546001600160a01b0319166001600160a01b039290921691909117905550620005d4565b5f82815260208190526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b5f80620002a98484620002d6565b90508015620002cd575f848152600160205260409020620002cb908462000381565b505b90505b92915050565b5f828152602081815260408083206001600160a01b038516845290915281205460ff1662000379575f838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055620003303390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620002d0565b505f620002d0565b5f620002cd836001600160a01b0384165f8181526001830160205260408120546200037957508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155620002d0565b615cc18062002a2183390190565b60405160a081016001600160401b03811182821017156200041557634e487b7160e01b5f52604160045260245ffd5b60405290565b604051608081016001600160401b03811182821017156200041557634e487b7160e01b5f52604160045260245ffd5b6001600160a01b03811681146200045f575f80fd5b50565b5f6060828403121562000473575f80fd5b604051606081016001600160401b0381118282101715620004a257634e487b7160e01b5f52604160045260245ffd5b80604052508091508251620004b7816200044a565b81526020830151620004c9816200044a565b60208201526040830151620004de816200044a565b6040919091015292915050565b5f818303610140811215620004fe575f80fd5b62000508620003e6565b835162000515816200044a565b8152602084015162000527816200044a565b602082015260408401516200053c816200044a565b60408201526080605f198301121562000553575f80fd5b6200055d6200041b565b915060608401516200056f816200044a565b8252608084015162000581816200044a565b602083015260a084015162000596816200044a565b604083015260c0840151620005ab816200044a565b80606084015250816060820152620005c78560e0860162000462565b6080820152949350505050565b60805160a05160c051612422620005ff5f395f6102c301525f61029b01525f61027601526124225ff3fe608060405234801562000010575f80fd5b50600436106200014c575f3560e01c80638d1cd1e411620000c3578063a8b81ea01162000083578063a8b81ea014620003df578063a8fc9e2914620003f6578063ca15c873146200041e578063d547741f1462000435578063ec87621c146200044c578063f83f55a91462000474575f80fd5b80638d1cd1e414620003495780639010d07c146200039557806391d1485414620003ac5780639cdf7d7414620003c3578063a217fddf14620003d7575f80fd5b806336568abe116200010f57806336568abe146200025457806354fd4d50146200026b5780635ec9a7a014620002f35780636c036fcf146200030a57806370824c5c1462000321575f80fd5b806301ffc9a71462000150578063248a9ca3146200017c57806329061c0514620001b05780632a36a161146200020b5780632f2ff15d146200023b575b5f80fd5b620001676200016136600462000c94565b6200049c565b60405190151581526020015b60405180910390f35b620001a16200018d36600462000cbd565b5f9081526020819052604090206001015490565b60405190815260200162000173565b600254600354600454600554620001d7936001600160a01b03908116938116928116911684565b604080516001600160a01b039586168152938516602085015291841691830191909152909116606082015260800162000173565b620002226200021c36600462001024565b620004c9565b6040516001600160a01b03909116815260200162000173565b620002526200024c36600462001113565b6200061c565b005b620002526200026536600462001113565b6200064a565b6040805163ffffffff7f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000000000000000000000000000000000000000000000811660208301527f0000000000000000000000000000000000000000000000000000000000000000169181019190915260600162000173565b620002526200030436600462001144565b62000685565b620002526200031b366004620011d3565b6200070f565b620001a17f797343f8d6a29aafeb3aaf0910a8973e0081c60c2f6c1f775cd9f76ea348fc1e81565b6006546007546008546200036a926001600160a01b03908116928116911683565b604080516001600160a01b039485168152928416602084015292169181019190915260600162000173565b62000222620003a6366004620011f1565b6200075e565b62000167620003bd36600462001113565b6200077e565b60095462000222906001600160a01b031681565b620001a15f81565b62000252620003f036600462001212565b620007a6565b620001a17faeaff0ba5714de3101330cd09333f32afb2556d1f0ec0469ef94ffe1e27c4bca81565b620001a16200042f36600462000cbd565b6200081c565b620002526200044636600462001113565b62000834565b620001a17f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0881565b620001a17f63d8e56f0160910d57b83f54cac0b3871607c2529985aa50e353236389f5acca81565b5f6001600160e01b03198216635a05180f60e01b1480620004c35750620004c3826200085c565b92915050565b5f7f797343f8d6a29aafeb3aaf0910a8973e0081c60c2f6c1f775cd9f76ea348fc1e620004f68162000892565b600254600954604080516101c08101825286516001600160a01b0390811682526020808901516001600160801b031916908301528783015192820192909252600554821660608083019190915287015160808083019190915287015160a08083019190915293821660c0808301829052600354841660e08401526004548416610100840152600654841661012084015260075484166101408401526008548416610160840152948801516101808301529387015161ffff166101a08201525f93620005c59390921690620008a1565b9050806001600160a01b031684602001516fffffffffffffffffffffffffffffffff19167fc76008eea2b9856c989708eb2d839fd92034836d5e29455a032c4afa6528ad5760405160405180910390a39392505050565b5f82815260208190526040902060010154620006388162000892565b62000644838362000931565b50505050565b6001600160a01b0381163314620006745760405163334bd91960e11b815260040160405180910390fd5b62000680828262000969565b505050565b7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08620006b18162000892565b508051600280546001600160a01b03199081166001600160a01b039384161790915560208301516003805483169184169190911790556040830151600480548316918416919091179055606090920151600580549093169116179055565b7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b086200073b8162000892565b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b5f82815260016020526040812062000777908362000999565b9392505050565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b7f63d8e56f0160910d57b83f54cac0b3871607c2529985aa50e353236389f5acca620007d28162000892565b508051600680546001600160a01b03199081166001600160a01b03938416179091556020830151600780548316918416919091179055604090920151600880549093169116179055565b5f818152600160205260408120620004c390620009a6565b5f82815260208190526040902060010154620008508162000892565b62000644838362000969565b5f6001600160e01b03198216637965db0b60e01b1480620004c357506301ffc9a760e01b6001600160e01b0319831614620004c3565b6200089e8133620009b0565b50565b5f80838563052548e960e01b85604051602401620008c0919062001358565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051620008ff9062000c86565b6200090d93929190620014ea565b604051809103905ff08015801562000927573d5f803e3d5ffd5b5095945050505050565b5f806200093f8484620009f4565b9050801562000777575f84815260016020526040902062000961908462000a89565b509392505050565b5f8062000977848462000a9f565b9050801562000777575f84815260016020526040902062000961908462000b0c565b5f62000777838362000b22565b5f620004c3825490565b620009bc82826200077e565b620009f05760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440160405180910390fd5b5050565b5f62000a0183836200077e565b62000a81575f838152602081815260408083206001600160a01b03861684529091529020805460ff1916600117905562000a383390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620004c3565b505f620004c3565b5f62000777836001600160a01b03841662000b4b565b5f62000aac83836200077e565b1562000a81575f838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001620004c3565b5f62000777836001600160a01b03841662000b92565b5f825f01828154811062000b3a5762000b3a62001554565b905f5260205f200154905092915050565b5f81815260018301602052604081205462000a8157508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155620004c3565b5f818152600183016020526040812054801562000c7c575f62000bb760018362001568565b85549091505f9062000bcc9060019062001568565b905080821462000c32575f865f01828154811062000bee5762000bee62001554565b905f5260205f200154905080875f01848154811062000c115762000c1162001554565b5f918252602080832090910192909255918252600188019052604090208390555b855486908062000c465762000c4662001588565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050620004c3565b5f915050620004c3565b610e50806200159d83390190565b5f6020828403121562000ca5575f80fd5b81356001600160e01b03198116811462000777575f80fd5b5f6020828403121562000cce575f80fd5b5035919050565b634e487b7160e01b5f52604160045260245ffd5b6040516060810167ffffffffffffffff8111828210171562000d0f5762000d0f62000cd5565b60405290565b60405160a0810167ffffffffffffffff8111828210171562000d0f5762000d0f62000cd5565b60405160e0810167ffffffffffffffff8111828210171562000d0f5762000d0f62000cd5565b604051601f8201601f1916810167ffffffffffffffff8111828210171562000d8d5762000d8d62000cd5565b604052919050565b6001600160a01b03811681146200089e575f80fd5b803562000db78162000d95565b919050565b80356001600160801b03198116811462000db7575f80fd5b80356001600160d01b03198116811462000db7575f80fd5b5f6060828403121562000dfd575f80fd5b62000e0762000ce9565b9050813562000e168162000d95565b815262000e266020830162000dd4565b602082015262000e396040830162000dd4565b604082015292915050565b5f67ffffffffffffffff82111562000e605762000e6062000cd5565b5060051b60200190565b803567ffffffffffffffff8116811462000db7575f80fd5b5f82601f83011262000e92575f80fd5b8135602062000eab62000ea58362000e44565b62000d61565b82815260a0928302850182019282820191908785111562000eca575f80fd5b8387015b8581101562000f5c5781818a03121562000ee6575f80fd5b62000ef062000d15565b62000efb8262000dbc565b81528582013562000f0c8162000d95565b81870152604062000f1f83820162000e6a565b90820152606062000f3283820162000e6a565b90820152608082810135801515811462000f4a575f80fd5b90820152845292840192810162000ece565b5090979650505050505050565b803561ffff8116811462000db7575f80fd5b5f82601f83011262000f8b575f80fd5b8135602062000f9e62000ea58362000e44565b8281526060928302850182019282820191908785111562000fbd575f80fd5b8387015b8581101562000f5c5781818a03121562000fd9575f80fd5b62000fe362000ce9565b62000fee8262000dbc565b81528582013562000fff8162000d95565b8187015260406200101283820162000f69565b90820152845292840192810162000fc1565b5f6020828403121562001035575f80fd5b813567ffffffffffffffff808211156200104d575f80fd5b90830190610120828603121562001062575f80fd5b6200106c62000d3b565b620010778362000daa565b8152620010876020840162000dbc565b60208201526200109b866040850162000dec565b604082015260a083013582811115620010b2575f80fd5b620010c08782860162000e82565b60608301525060c083013582811115620010d8575f80fd5b620010e68782860162000f7b565b60808301525060e083013560a082015262001105610100840162000f69565b60c082015295945050505050565b5f806040838503121562001125575f80fd5b823591506020830135620011398162000d95565b809150509250929050565b5f6080828403121562001155575f80fd5b6040516080810181811067ffffffffffffffff821117156200117b576200117b62000cd5565b60405282356200118b8162000d95565b815260208301356200119d8162000d95565b60208201526040830135620011b28162000d95565b60408201526060830135620011c78162000d95565b60608201529392505050565b5f60208284031215620011e4575f80fd5b8135620007778162000d95565b5f806040838503121562001203575f80fd5b50508035926020909101359150565b5f6060828403121562001223575f80fd5b6200122d62000ce9565b82356200123a8162000d95565b815260208301356200124c8162000d95565b60208201526040830135620012618162000d95565b60408201529392505050565b5f815180845260208085019450602084015f5b83811015620012ef57815180516001600160801b0319168852838101516001600160a01b03168489015260408082015167ffffffffffffffff908116918a01919091526060808301519091169089015260809081015115159088015260a0909601959082019060010162001280565b509495945050505050565b5f815180845260208085019450602084015f5b83811015620012ef57815180516001600160801b0319168852838101516001600160a01b03168489015260409081015161ffff1690880152606090960195908201906001016200130d565b60208152620013736020820183516001600160a01b03169052565b5f60208301516200139060408401826001600160801b0319169052565b5060408381015180516001600160a01b0316606085015260208101516001600160d01b031990811660808601529181015190911660a08401525060608301516001600160a01b03811660c08401525060808301516102008060e0850152620013fd6102208501836200126d565b915060a0850151610100601f1986850301818701526200141e8483620012fa565b935060c087015191506101206200143f818801846001600160a01b03169052565b60e088015192506101406200145e818901856001600160a01b03169052565b918801519250610160916200147d888401856001600160a01b03169052565b908801519250610180906200149c888301856001600160a01b03169052565b88015192506101a0620014b9888201856001600160a01b03169052565b918801516001600160a01b03166101c08801528701516101e0870152959095015161ffff1693019290925250919050565b5f60018060a01b0380861683526020818616602085015260606040850152845191508160608501525f5b82811015620015325785810182015185820160800152810162001514565b50505f608082850101526080601f19601f830116840101915050949350505050565b634e487b7160e01b5f52603260045260245ffd5b81810381811115620004c357634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b5f52603160045260245ffdfe60a060405260405162000e5038038062000e508339810160408190526200002691620003bc565b828162000034828262000099565b50508160405162000045906200035a565b6001600160a01b039091168152602001604051809103905ff0801580156200006f573d5f803e3d5ffd5b506001600160a01b0316608052620000906200008a60805190565b620000fe565b505050620004b3565b620000a4826200016f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2805115620000f057620000eb8282620001ee565b505050565b620000fa62000267565b5050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200013f5f8051602062000e30833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a16200016c8162000289565b50565b806001600160a01b03163b5f03620001aa57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b60605f80846001600160a01b0316846040516200020c919062000496565b5f60405180830381855af49150503d805f811462000246576040519150601f19603f3d011682016040523d82523d5f602084013e6200024b565b606091505b5090925090506200025e858383620002ca565b95945050505050565b3415620002875760405163b398979f60e01b815260040160405180910390fd5b565b6001600160a01b038116620002b457604051633173bdd160e11b81525f6004820152602401620001a1565b805f8051602062000e30833981519152620001cd565b606082620002e357620002dd8262000330565b62000329565b8151158015620002fb57506001600160a01b0384163b155b156200032657604051639996b31560e01b81526001600160a01b0385166004820152602401620001a1565b50805b9392505050565b805115620003415780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6104fc806200093483390190565b80516001600160a01b03811681146200037f575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f5b83811015620003b45781810151838201526020016200039a565b50505f910152565b5f805f60608486031215620003cf575f80fd5b620003da8462000368565b9250620003ea6020850162000368565b60408501519092506001600160401b038082111562000407575f80fd5b818601915086601f8301126200041b575f80fd5b81518181111562000430576200043062000384565b604051601f8201601f19908116603f011681019083821181831017156200045b576200045b62000384565b8160405282815289602084870101111562000474575f80fd5b6200048783602083016020880162000398565b80955050505050509250925092565b5f8251620004a981846020870162000398565b9190910192915050565b608051610469620004cb5f395f601001526104695ff3fe608060405261000c61000e565b005b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361007a575f356001600160e01b03191663278f794360e11b14610070576040516334ad5dbb60e21b815260040160405180910390fd5b610078610082565b565b6100786100b0565b5f806100913660048184610303565b81019061009e919061033e565b915091506100ac82826100c0565b5050565b6100786100bb61011a565b610151565b6100c98261016f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156101125761010d82826101ea565b505050565b6100ac61025c565b5f61014c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b365f80375f80365f845af43d5f803e80801561016b573d5ff35b3d5ffd5b806001600160a01b03163b5f036101a957604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516102069190610407565b5f60405180830381855af49150503d805f811461023e576040519150601f19603f3d011682016040523d82523d5f602084013e610243565b606091505b509150915061025385838361027b565b95945050505050565b34156100785760405163b398979f60e01b815260040160405180910390fd5b6060826102905761028b826102da565b6102d3565b81511580156102a757506001600160a01b0384163b155b156102d057604051639996b31560e01b81526001600160a01b03851660048201526024016101a0565b50805b9392505050565b8051156102ea5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f8085851115610311575f80fd5b8386111561031d575f80fd5b5050820193919092039150565b634e487b7160e01b5f52604160045260245ffd5b5f806040838503121561034f575f80fd5b82356001600160a01b0381168114610365575f80fd5b9150602083013567ffffffffffffffff80821115610381575f80fd5b818501915085601f830112610394575f80fd5b8135818111156103a6576103a661032a565b604051601f8201601f19908116603f011681019083821181831017156103ce576103ce61032a565b816040528281528860208487010111156103e6575f80fd5b826020860160208301375f6020848301015280955050505050509250929050565b5f82515f5b81811015610426576020818601810151858301520161040c565b505f92019182525091905056fea2646970667358221220740d83b0f0314c5a4b4f3771cc54601255c45b2e55a7df3cdfd8149f584102c864736f6c63430008170033608060405234801561000f575f80fd5b506040516104fc3803806104fc83398101604081905261002e916100bb565b806001600160a01b03811661005c57604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6100658161006c565b50506100e8565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f602082840312156100cb575f80fd5b81516001600160a01b03811681146100e1575f80fd5b9392505050565b610407806100f55f395ff3fe608060405260043610610049575f3560e01c8063715018a61461004d5780638da5cb5b146100635780639623609d1461008e578063ad3cb1cc146100a1578063f2fde38b146100de575b5f80fd5b348015610058575f80fd5b506100616100fd565b005b34801561006e575f80fd5b505f546040516001600160a01b0390911681526020015b60405180910390f35b61006161009c366004610260565b610110565b3480156100ac575f80fd5b506100d1604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516100859190610372565b3480156100e9575f80fd5b506100616100f836600461038b565b61017b565b6101056101bd565b61010e5f6101e9565b565b6101186101bd565b60405163278f794360e11b81526001600160a01b03841690634f1ef28690349061014890869086906004016103a6565b5f604051808303818588803b15801561015f575f80fd5b505af1158015610171573d5f803e3d5ffd5b5050505050505050565b6101836101bd565b6001600160a01b0381166101b157604051631e4fbdf760e01b81525f60048201526024015b60405180910390fd5b6101ba816101e9565b50565b5f546001600160a01b0316331461010e5760405163118cdaa760e01b81523360048201526024016101a8565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146101ba575f80fd5b634e487b7160e01b5f52604160045260245ffd5b5f805f60608486031215610272575f80fd5b833561027d81610238565b9250602084013561028d81610238565b9150604084013567ffffffffffffffff808211156102a9575f80fd5b818601915086601f8301126102bc575f80fd5b8135818111156102ce576102ce61024c565b604051601f8201601f19908116603f011681019083821181831017156102f6576102f661024c565b8160405282815289602084870101111561030e575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f81518084525f5b8181101561035357602081850181015186830182015201610337565b505f602082860101526020601f19601f83011685010191505092915050565b602081525f610384602083018461032f565b9392505050565b5f6020828403121561039b575f80fd5b813561038481610238565b6001600160a01b03831681526040602082018190525f906103c99083018461032f565b94935050505056fea26469706673582212200908d16c57edc2c24f442a05324b350d6ce826315cc6002bcfaa956b1d16717464736f6c63430008170033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103a2646970667358221220f1478fc88a0dc9bfb10bdb82055460989f5a8def8b323865b1d232a095a776ae64736f6c6343000817003360e060405234801562000010575f80fd5b5060026080525f60a081905260c052620000296200002f565b620000e3565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000805760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000e05780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b60805160a05160c051615bb36200010e5f395f61060401525f6105dc01525f6105b70152615bb35ff3fe608060405234801561000f575f80fd5b5060043610610392575f3560e01c80638456cb59116101df578063b82538bd11610109578063e2ca5974116100a9578063f83f55a911610079578063f83f55a914610927578063fc0c546a1461093b578063fdf25f331461094e578063ff3c2f8914610961575f80fd5b8063e2ca5974146108d1578063e63ab1e9146108e4578063ec87621c1461090b578063f698da251461091f575f80fd5b8063cf055d5c116100e4578063cf055d5c1461088d578063d547741f146108a1578063d54ad2a1146108b4578063e00549ab146108bd575f80fd5b8063b82538bd14610841578063c824166f14610867578063ca15c8731461087a575f80fd5b8063a217fddf1161017f578063ae2560af1161014f578063ae2560af146107d6578063b212f067146107e9578063b3061b911461081b578063b6870c5a1461082e575f80fd5b8063a217fddf1461078a578063a377052314610791578063a8981e731461079a578063a8fc9e29146107af575f80fd5b80639010d07c116101ba5780639010d07c1461074857806391d148541461075b5780639dc69e1f1461076e578063a1ebf35d14610776575f80fd5b80638456cb591461071c57806384b0196e146107245780638f22602e1461073f575f80fd5b80633f953f9a116102c05780635f3e849f116102605780636adc3168116102305780636adc31681461069357806370824c5c146106c257806373852d27146106e95780638164183e14610709575f80fd5b80635f3e849f14610646578063601ed31b14610659578063652cce511461066c5780636aa633b61461067f575f80fd5b80634407390d1161029b5780634407390d146105865780634925abac1461059957806354fd4d50146105ac57806358941f1e14610633575f80fd5b80633f953f9a1461054a57806340b40f551461055d5780634111bf9d1461057d575f80fd5b806326e670ea11610336578063342cf27a11610306578063342cf27a1461050757806336568abe1461051a5780633ba930ad1461052d5780633d24f8f714610542575f80fd5b806326e670ea146104ae5780632f2ff15d146104ce5780632fc2ec02146104e1578063328d8f72146104f4575f80fd5b806319a1e5871161037157806319a1e5871461042d57806320ab083e146104415780632257310f1461046c578063248a9ca31461048d575f80fd5b80620769431461039657806301ffc9a7146103f5578063052548e914610418575b5f80fd5b5f546103c0906001600160a01b03811690600160a01b810460d090811b91600160d01b9004901b83565b604080516001600160a01b0390941684526001600160d01b031992831660208501529116908201526060015b60405180910390f35b610408610403366004614687565b610974565b60405190151581526020016103ec565b61042b6104263660046149ef565b61099e565b005b60025461040890600160a81b900460ff1681565b600154610454906001600160a01b031681565b6040516001600160a01b0390911681526020016103ec565b60075461047a9061ffff1681565b60405161ffff90911681526020016103ec565b6104a061049b366004614b4f565b610d7c565b6040519081526020016103ec565b6104c16104bc366004614bad565b610d9c565b6040516103ec9190614c25565b61042b6104dc366004614c37565b610e66565b61042b6104ef366004614c65565b610e88565b61042b610502366004614cd8565b610efa565b6104c1610515366004614cf3565b610f1e565b61042b610528366004614c37565b610ff8565b60035461047a90600160c01b900461ffff1681565b61042b611030565b61042b610558366004614db0565b611082565b61057061056b366004614bad565b6110f3565b6040516103ec9190614de2565b6104a0600a5481565b61042b610594366004614e39565b6111ec565b6104c16105a7366004614bad565b611226565b6040805163ffffffff7f0000000000000000000000000000000000000000000000000000000000000000811682527f0000000000000000000000000000000000000000000000000000000000000000811660208301527f000000000000000000000000000000000000000000000000000000000000000016918101919091526060016103ec565b61042b610641366004614cd8565b61131a565b61042b610654366004614e54565b611350565b61042b610667366004614e92565b61137b565b61042b61067a366004614b4f565b611419565b60025461040890600160a01b900460ff1681565b5f805260096020527fec8156718a8372b1db44bb411437d0870f3e3790d4a08526d024ce1b0b668f6b546104a0565b6104a07f797343f8d6a29aafeb3aaf0910a8973e0081c60c2f6c1f775cd9f76ea348fc1e81565b6106fc6106f7366004614bad565b6115cc565b6040516103ec9190614ea8565b61042b610717366004614db0565b6116cc565b61042b611815565b61072c61184b565b6040516103ec9796959493929190614f43565b6104a060065481565b610454610756366004614fb2565b6118f4565b610408610769366004614c37565b611921565b6104a0611957565b6104a05f80516020615afe83398151915281565b6104a05f81565b6104a060055481565b6107a2611970565b6040516103ec9190614fd2565b6104a07faeaff0ba5714de3101330cd09333f32afb2556d1f0ec0469ef94ffe1e27c4bca81565b6104c16107e4366004614bad565b6119f2565b60035461080390600160801b90046001600160401b031681565b6040516001600160401b0390911681526020016103ec565b61042b61082936600461501f565b611aae565b6104c161083c366004615048565b611b8e565b60035461084e9060801b81565b6040516001600160801b031990911681526020016103ec565b61042b6108753660046150d1565b611cb9565b6104a0610888366004614b4f565b611d9a565b6104a05f80516020615ade83398151915281565b61042b6108af366004614c37565b611dbe565b6104a060045481565b6104a05f80516020615b5e83398151915281565b61042b6108df3660046150ea565b611dda565b6104a07f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a81565b6104a05f80516020615abe83398151915281565b6104a0611ee4565b6104a05f80516020615b3e83398151915281565b600254610454906001600160a01b031681565b61042b61095c3660046151a5565b611eed565b61042b61096f366004615220565b612318565b5f6001600160e01b03198216635a05180f60e01b148061099857506109988261236d565b92915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03165f811580156109e25750825b90505f826001600160401b031660011480156109fd5750303b155b905081158015610a0b575080155b15610a295760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610a5357845460ff60401b1916600160401b1785555b610a5b6123a1565b610aa16040518060400160405280600b81526020016a2234b9ba3934b13aba37b960a91b815250604051806040016040528060018152602001603160f81b8152506123a9565b610ad85f80516020615b3e8339815191527faeaff0ba5714de3101330cd09333f32afb2556d1f0ec0469ef94ffe1e27c4bca6123bb565b610afc5f80516020615afe8339815191525f80516020615b3e8339815191526123bb565b610b205f80516020615ade8339815191525f80516020615b3e8339815191526123bb565b610b305f801b8760c0015161241b565b50610b4c5f80516020615abe8339815191528760e0015161241b565b50610b7c7faeaff0ba5714de3101330cd09333f32afb2556d1f0ec0469ef94ffe1e27c4bca87610100015161241b565b50610b995f80516020615b3e83398151915287610120015161241b565b50610bb65f80516020615afe83398151915287610140015161241b565b50610bd35f80516020615ade83398151915287610160015161241b565b50610c037f797343f8d6a29aafeb3aaf0910a8973e0081c60c2f6c1f775cd9f76ea348fc1e87610160015161241b565b50610c337f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a87610160015161241b565b50610c41866040015161245d565b60408681015180515f805460208085015194909501516001600160a01b039384166001600160d01b031990921691909117600160a01b60d095861c02176001600160d01b0316600160d01b9190941c02929092179091556060880151600180546001600160a01b03199081169284169290921790558851600280549092169216919091179055860151600380546001600160801b031916608092831c1790556101a08701516007805461ffff191661ffff909216919091179055860151610180870151610d0e91906125d4565b610d1b8660a0015161288e565b6002805460ff60a01b1916600160a01b1790558315610d7457845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b5f9081525f80516020615b1e833981519152602052604090206001015490565b60605f826001600160401b03811115610db757610db76146ae565b604051908082528060200260200182016040528015610de0578160200160208202803683370190505b5090505f5b83811015610e5e5760095f868684818110610e0257610e026152f4565b9050602002016020810190610e179190615308565b6001600160801b0319166001600160801b03191681526020019081526020015f2054828281518110610e4b57610e4b6152f4565b6020908102919091010152600101610de5565b509392505050565b610e6f82610d7c565b610e7881612b82565b610e82838361241b565b50505050565b5f80516020615abe833981519152610e9f81612b82565b610e828484808060200260200160405190810160405280939291908181526020015f905b82821015610eef57610ee060a08302860136819003810190615321565b81526020019060010190610ec3565b5050505050836125d4565b5f80516020615b3e833981519152610f1181612b82565b610f1a82612b8c565b5050565b60605f856001600160401b03811115610f3957610f396146ae565b604051908082528060200260200182016040528015610f62578160200160208202803683370190505b5090505f5b86811015610feb57610fc6888883818110610f8457610f846152f4565b9050602002016020810190610f999190615308565b878784818110610fab57610fab6152f4565b9050602002016020810190610fc0919061533b565b86612c0c565b828281518110610fd857610fd86152f4565b6020908102919091010152600101610f67565b5090505b95945050505050565b6001600160a01b03811633146110215760405163334bd91960e11b815260040160405180910390fd5b61102b8282612d6c565b505050565b604080516060810182525f546001600160a01b03811682526001600160d01b0319600160a01b820460d090811b82166020850152600160d01b90920490911b169181019190915261108090612da5565b565b5f80516020615abe83398151915261109981612b82565b61102b8383808060200260200160405190810160405280939291908181526020015f905b828210156110e9576110da60608302860136819003810190615356565b815260200190600101906110bd565b505050505061288e565b60605f826001600160401b0381111561110e5761110e6146ae565b60405190808252806020026020018201604052801561115257816020015b604080518082019091525f808252602082015281526020019060019003908161112c5790505b5090505f5b83811015610e5e5760085f868684818110611174576111746152f4565b90506020020160208101906111899190615308565b6001600160801b031916815260208082019290925260409081015f20815180830190925280548252600101546001600160401b03169181019190915282518390839081106111d9576111d96152f4565b6020908102919091010152600101611157565b5f80516020615abe83398151915261120381612b82565b50600180546001600160a01b0319166001600160a01b0392909216919091179055565b60605f826001600160401b03811115611241576112416146ae565b60405190808252806020026020018201604052801561126a578160200160208202803683370190505b5090505f5b83811015610e5e576112f585858381811061128c5761128c6152f4565b90506020020160208101906112a19190615308565b600b5f8888868181106112b6576112b66152f4565b90506020020160208101906112cb9190615308565b6001600160801b031916815260208101919091526040015f2054600160a01b900461ffff16612f7e565b828281518110611307576113076152f4565b602090810291909101015260010161126f565b5f80516020615abe83398151915261133181612b82565b5060028054911515600160a81b0260ff60a81b19909216919091179055565b5f80516020615abe83398151915261136781612b82565b610e826001600160a01b0385168484612fc0565b5f80516020615b3e83398151915261139281612b82565b6113a96113a436849003840184615370565b61245d565b815f6113b5828261538a565b505060405163601ed31b60e01b907f11f2fec7a1604d7d8ea8b74ed1666060410561f7e666aee037dcf3f9292cb4c1906113f39085906020016153fd565b60408051601f198184030181529082905261140d91615455565b60405180910390a25050565b5f80516020615ade83398151915261143081612b82565b600154604051639d84ae6960e01b81527f35bd7c3085200665404055ee8facd7c7cf131f375247edf256b95933d81b07b460048201525f916001600160a01b031690639d84ae6990602401602060405180830381865afa158015611496573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906114ba91906154a8565b6007549091505f906114d190829061ffff16612f7e565b90508084111561150357604051630f4da97960e41b815260048101859052602481018290526044015b60405180910390fd5b5f80805260096020527fec8156718a8372b1db44bb411437d0870f3e3790d4a08526d024ce1b0b668f6b805486929061153d9084906154d7565b925050819055508360065f82825461155591906154d7565b90915550506003546040516001600160a01b038416915f9160809190911b6001600160801b031916907f7ed4454676b40d92244b47fc7a6ef3aab0808cbf85d84fc65676a040343d4823906115ad9089815260200190565b60405180910390a4600254610e82906001600160a01b03168386612fc0565b60605f826001600160401b038111156115e7576115e76146ae565b60405190808252806020026020018201604052801561162b57816020015b604080518082019091525f80825260208201528152602001906001900390816116055790505b5090505f5b83811015610e5e57600b5f86868481811061164d5761164d6152f4565b90506020020160208101906116629190615308565b6001600160801b031916815260208082019290925260409081015f208151808301909252546001600160a01b0381168252600160a01b900461ffff169181019190915282518390839081106116b9576116b96152f4565b6020908102919091010152600101611630565b5f80516020615b5e8339815191526116e381612b82565b6004545f5b8381101561180c575f858583818110611703576117036152f4565b6117199260206060909202019081019150615308565b90503686868481811061172e5761172e6152f4565b90506060020160200190505f81602001602081019061174d919061533b565b6001600160401b03161115155f825f01351115151461178b576040516329a440e160e01b81526001600160801b0319831660048201526024016114fa565b6001600160801b031982165f90815260086020526040902054156117ce5760405163536c104560e11b81526001600160801b0319831660048201526024016114fa565b6001600160801b031982165f90815260086020526040902081906117f282826154ea565b5061180090508135856154d7565b935050506001016116e8565b50600455505050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a61183f81612b82565b6118485f612b8c565b50565b5f60608082808083815f80516020615a9e833981519152805490915015801561187657506001810154155b6118ba5760405162461bcd60e51b81526020600482015260156024820152741152540dcc4c8e88155b9a5b9a5d1a585b1a5e9959605a1b60448201526064016114fa565b6118c2613012565b6118ca6130d2565b604080515f80825260208201909252600f60f81b9c939b5091995046985030975095509350915050565b5f8281525f80516020615a7e8339815191526020819052604082206119199084613110565b949350505050565b5f9182525f80516020615b1e833981519152602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6007545f9061196b90829061ffff16612f7e565b905090565b6060600c8054806020026020016040519081016040528092919081815260200182805480156119e857602002820191905f5260205f20905f905b82829054906101000a900460801b6001600160801b03191681526020019060100190602082600f010492830192600103820291508084116119aa5790505b5050505050905090565b60605f826001600160401b03811115611a0d57611a0d6146ae565b604051908082528060200260200182016040528015611a36578160200160208202803683370190505b5090505f5b83811015610e5e5760085f868684818110611a5857611a586152f4565b9050602002016020810190611a6d9190615308565b6001600160801b031916815260208101919091526040015f20548251839083908110611a9b57611a9b6152f4565b6020908102919091010152600101611a3b565b5f80516020615b5e833981519152611ac581612b82565b60058490556004548314611b1d57600480546040516315d3fa8760e01b8152606092810192909252600c60648301526b1d1bdd185b10db185a5b595960a21b608483015260248201526044810184905260a4016114fa565b8160065414611b77576006546040516315d3fa8760e01b81526060600482015260136064820152723a37ba30b621b0b9393cabb4ba34323930bbb760691b608482015260248101919091526044810183905260a4016114fa565b610e825f80516020615b5e83398151915233610ff8565b60605f836001600160401b03811115611ba957611ba96146ae565b604051908082528060200260200182016040528015611bd2578160200160208202803683370190505b5090505f5b84811015611cae57611c89868683818110611bf457611bf46152f4565b611c0a9260206080909202019081019150615308565b878784818110611c1c57611c1c6152f4565b9050608002016020016020810190611c34919061533b565b6001600160401b0316888885818110611c4f57611c4f6152f4565b9050608002016040016020810190611c679190614cd8565b898986818110611c7957611c796152f4565b905060800201606001358861311b565b828281518110611c9b57611c9b6152f4565b6020908102919091010152600101611bd7565b5090505b9392505050565b5f80516020615abe833981519152611cd081612b82565b6107d08261ffff161115611d3d576040516301f6ffb960e31b815260206004820152602d60248201527f506c6174666f726d206361727279204250532063616e6e6f742062652067726560448201526c61746572207468616e2032302560981b60648201526084016114fa565b6007546003548391611d5e9161ffff91821691600160c01b90910416615520565b611d68919061553b565b6003805461ffff60c01b1916600160c01b61ffff938416021790556007805461ffff1916939091169290921790915550565b5f8181525f80516020615a7e833981519152602081905260408220611cb2906131b4565b611dc782610d7c565b611dd081612b82565b610e828383612d6c565b5f80516020615b5e833981519152611df181612b82565b6006545f5b83811015611edb575f858583818110611e1157611e116152f4565b611e279260206040909202019081019150615308565b6001600160801b031981165f9081526009602052604090205490915015611e6d576040516315adf33960e21b81526001600160801b0319821660048201526024016114fa565b858583818110611e7f57611e7f6152f4565b6001600160801b031984165f908152600960209081526040918290209190920293909301013590915550858583818110611ebb57611ebb6152f4565b9050604002016020013583611ed091906154d7565b925050600101611df6565b50600655505050565b5f61196b6131bd565b600254600160a01b900460ff1680611f1857604051633ac4266d60e11b815260040160405180910390fd5b60035460801b6001600160801b031916611f356020880188615308565b6001600160801b03191614611f8857611f516020870187615308565b6003546040516308d9a7fb60e41b81526114fa929160801b906004016001600160801b031992831681529116602082015260400190565b85608001354210611fb257604051630f5f3b2360e41b8152608087013560048201526024016114fa565b5f600b81611fc660408a0160208b01615308565b6001600160801b031916815260208082019290925260409081015f208151808301909252546001600160a01b038116808352600160a01b90910461ffff1692820192909252915061202a57604051637d469caf60e11b815260040160405180910390fd5b5f61204a61203d368a90038a018a615556565b6120456131bd565b6131c6565b600254909150600160a81b900460ff161580156120a757506120a5825f01518289898080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061328b92505050565b155b1561211e575f6120ec8289898080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506132ea92505050565b8351604051631fb7a3a360e01b81526001600160a01b03808416600483015290911660248201529091506044016114fa565b5f61215e8287878080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506132ea92505050565b90506121775f80516020615afe83398151915282611921565b61219f576040516301120d5160e31b81526001600160a01b03821660048201526024016114fa565b505f90506121c06121b660408a0160208b01615308565b8360200151612f7e565b905080886060013511156121f457604051630f4da97960e41b815260608901356004820152602481018290526044016114fa565b50606087013560095f61220d60408b0160208c01615308565b6001600160801b0319166001600160801b03191681526020019081526020015f205f82825461223c91906154d7565b92505081905550866060013560065f82825461225891906154d7565b9091555061226e90506060880160408901614e39565b6001600160a01b03166122876040890160208a01615308565b6001600160801b03191661229e60208a018a615308565b6001600160801b0319167f7ed4454676b40d92244b47fc7a6ef3aab0808cbf85d84fc65676a040343d48238a606001356040516122dd91815260200190565b60405180910390a461230f6122f86060890160408a01614e39565b6002546001600160a01b03169060608a0135612fc0565b50505050505050565b600254600160a01b900460ff168061234357604051633ac4266d60e11b815260040160405180910390fd5b811561235157612351611030565b6123618a8a8a8a8a8a8a8a613312565b50505050505050505050565b5f6001600160e01b03198216637965db0b60e01b148061099857506301ffc9a760e01b6001600160e01b0319831614610998565b6110806137d6565b6123b16137d6565b610f1a828261381f565b5f80516020615b1e8339815191525f6123d384610d7c565b5f85815260208490526040808220600101869055519192508491839187917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a450505050565b5f5f80516020615a7e83398151915281612435858561387e565b90508015611919575f8581526020839052604090206124549085613926565b50949350505050565b80516001600160a01b03166124f85760208101516001600160d01b031916151580612495575060408101516001600160d01b03191615155b1561184857604051632e3505a960e01b815260206004820152602c60248201527f756e6c6f636b657220697320756e736574206275742066756e6374696f6e207460448201526b1e5c195cc8185c99481cd95d60a21b60648201526084016114fa565b60208101516001600160d01b031916650448a88550a960d11b14801590612536575060208101516001600160d01b031916654d8ad6b7fe1b60d01b14155b1561256657602081015160405163084523c560e11b81526001600160d01b031990911660048201526024016114fa565b60408101516001600160d01b031916650448a88550a960d11b148015906125a4575060408101516001600160d01b031916654d8ad6b7fe1b60d01b14155b1561184857604080820151905163084523c560e11b81526001600160d01b031990911660048201526024016114fa565b5f8083516001600160401b038111156125ef576125ef6146ae565b604051908082528060200260200182016040528015612618578160200160208202803683370190505b5090505f5b845181101561282d575f858281518110612639576126396152f4565b602090810291909101015180519091506001600160801b031916612670576040516301f6ffb960e31b81526004016114fa906155ba565b60208101516001600160a01b03166126bc576040516301f6ffb960e31b815260206004820152600e60248201526d7369676e6572206973207a65726f60901b60448201526064016114fa565b80604001516001600160401b03165f03612719576040516301f6ffb960e31b815260206004820152601760248201527f616d6f756e7420696e766573746564206973207a65726f00000000000000000060448201526064016114fa565b80606001516001600160401b03165f03612776576040516301f6ffb960e31b815260206004820152601a60248201527f646973747269627574696f6e536861726573206973207a65726f00000000000060448201526064016114fa565b60608101516127859085615606565b6040805183516001600160801b0319166020808301919091528401516001600160a01b031681830152908301516001600160401b0390811660608084019190915284015116608080830191909152830151151560a08201529094506128079060c0015b60405160208183030381529060405280516020918201205f9081522090565b838381518110612819576128196152f4565b60209081029190910101525060010161261d565b506003805467ffffffffffffffff60801b1916600160801b6001600160401b038516021790555f61285d8261393a565b9050838114612885578181856040516316af695b60e11b81526004016114fa93929190615626565b600a5550505050565b600c548015612910575f5b8181101561290457600b5f600c83815481106128b7576128b76152f4565b5f918252602080832060028304015460019283166010026101000a900460801b6001600160801b03191684528301939093526040909101902080546001600160b01b031916905501612899565b50612910600c5f614652565b5f805b8351811015612b4f575f84828151811061292f5761292f6152f4565b602090810291909101015180519091506001600160801b031916612966576040516301f6ffb960e31b81526004016114fa906155ba565b60208101516001600160a01b03166129b2576040516301f6ffb960e31b815260206004820152600e60248201526d7369676e6572206973207a65726f60901b60448201526064016114fa565b806040015161ffff165f036129fe576040516301f6ffb960e31b8152602060048201526011602482015270636172727920425053206973207a65726f60781b60448201526064016114fa565b80516001600160801b0319165f908152600b60205260409020546001600160a01b031615612a6f576040516301f6ffb960e31b815260206004820152601960248201527f656e746974795555494420616c7265616479206578697374730000000000000060448201526064016114fa565b6040810151612a7e908461553b565b8151600c8054600180820183555f9283527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c7600283040180546001600160801b039383166010026101000a938402191660809590951c929092029390931790556040805180820182526020808701516001600160a01b0390811683528388015161ffff90811683850190815298516001600160801b0319168652600b9092529290932090518154965192166001600160b01b031990961695909517600160a01b919092160217909255925001612913565b50600754612b619061ffff168261553b565b600360186101000a81548161ffff021916908361ffff160217905550505050565b6118488133613995565b60028054821515600160a01b0260ff60a01b19909116179055604051631946c7b960e11b907f11f2fec7a1604d7d8ea8b74ed1666060410561f7e666aee037dcf3f9292cb4c190612be7908490602001901515815260200190565b60408051601f1981840301815290829052612c0191615674565b60405180910390a250565b5f80600654600554600454612c2191906156ad565b6002546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015612c67573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c8b91906156c0565b612c9591906154d7565b612c9f91906154d7565b90508215612d0457604080516060810182525f546001600160a01b03811682526001600160d01b0319600160a01b820460d090811b82166020850152600160d01b90920490911b1691810191909152612cf7906139ce565b612d0190826154d7565b90505b6003545f90612d289083906001600160401b0380891691600160801b900416613af5565b6001600160801b031987165f9081526008602052604090205490915080821015612d57575f9350505050611cb2565b612d6181836156ad565b979650505050505050565b5f5f80516020615a7e83398151915281612d868585613bb4565b90508015611919575f8581526020839052604090206124549085613c2d565b80516001600160a01b0316612db75750565b60408101516001600160d01b031916657bb7577aaf5760d11b01612e8f57805f01516001600160a01b03166386d1a69f6040518163ffffffff1660e01b81526004015f604051808303815f87803b158015612e10575f80fd5b505af1925050508015612e21575060015b611848573d808015612e4e576040519150601f19603f3d011682016040523d82523d5f602084013e612e53565b606091505b507fd4dda53af3bad1326f8c4a3308709c8621ff0cf0691b7a3052e2fcda2f9141db81604051612e8391906156d7565b60405180910390a15050565b60408101516001600160d01b03191665b275294801e560d01b01612f535780516040516370a0823160e01b81523060048201526001600160a01b03909116906311bcc81e9082906370a0823190602401602060405180830381865afa158015612efa573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f1e91906156c0565b6040518263ffffffff1660e01b8152600401612f3c91815260200190565b5f604051808303815f87803b158015612e10575f80fd5b604080820151905163084523c560e11b81526001600160d01b031990911660048201526024016114fa565b6001600160801b031982165f90815260096020526040812054600554600354612fb6919061ffff80871691600160c01b900416613af5565b611cb291906156ad565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261102b908490613c41565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10280546060915f80516020615a9e83398151915291613050906156e9565b80601f016020809104026020016040519081016040528092919081815260200182805461307c906156e9565b80156130c75780601f1061309e576101008083540402835291602001916130c7565b820191905f5260205f20905b8154815290600101906020018083116130aa57829003601f168201915b505050505091505090565b7fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10380546060915f80516020615a9e83398151915291613050906156e9565b5f611cb28383613ca2565b5f831561312957505f610fef565b5f6131438461313d36869003860186615767565b90613cc8565b6001600160801b031988165f90815260086020526040812060010154600354929350909161318b9189916001600160401b03909116908590600160c01b900461ffff16613cdb565b90505f6131a7826131a136889003880188615767565b90613d1d565b9998505050505050505050565b5f610998825490565b5f61196b613d30565b5f807f4d9f77ff47b5a86f69f849f0468d24908e3c97653ee3cbecc5bb86ff0f7de941845f0151856020015186604001518760600151886080015160405160200161324f969594939291909586526001600160801b031994851660208701529290931660408501526001600160a01b03166060840152608083019190915260a082015260c00190565b604051602081830303815290604052805190602001209050611919838260405161190160f01b8152600281019290925260228201526042902090565b5f805f6132988585613da3565b5090925090505f8160038111156132b1576132b1615781565b1480156132cf5750856001600160a01b0316826001600160a01b0316145b806132e057506132e0868686613dec565b9695505050505050565b5f805f806132f88686613da3565b9250925092506133088282613ec2565b5090949350505050565b60035460801b6001600160801b03191661332f60208a018a615308565b6001600160801b0319161461334b57611f516020890189615308565b8760c00135421061337557604051630f5f3b2360e41b815260c089013560048201526024016114fa565b5f61338a846040516020016127e89190615795565b90505f613398848484613f7a565b9050600a5481146133d157600a5460405163117cd02b60e01b8152600481018490526024810183905260448101919091526064016114fa565b505f90506133f46133e7368b90038b018b61581a565b6133ef6131bd565b613fb2565b600254909150600160a81b900460ff1615801561345d575061345b61341f6040860160208701614e39565b828a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525061328b92505050565b155b156134e1575f6134a2828a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506132ea92505050565b9050806134b56040870160208801614e39565b604051631fb7a3a360e01b81526001600160a01b039283166004820152911660248201526044016114fa565b5f6135218288888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152506132ea92505050565b905061353a5f80516020615afe83398151915282611921565b613562576040516301120d5160e31b81526001600160a01b03821660048201526024016114fa565b505f905060088161357960408c0160208d01615308565b6001600160801b0319166001600160801b03191681526020019081526020015f2090505f6135c98a60200160208101906135b39190615308565b6135c3608088016060890161533b565b5f612c0c565b9050808a6060013511156135fd576040516372b4ba4160e11b815260608b01356004820152602481018290526044016114fa565b505f61361960608b013561313d368d90038d0160808e01615767565b90505f61366661362f60408d0160208e01615308565b61363f6060890160408a0161533b565b6001600160401b031661365860a08a0160808b01614cd8565b8e606001358f60800161311b565b90508a60600135835f015f82825461367e91906154d7565b90915550506001830180548391905f906136a29084906001600160401b0316615606565b92506101000a8154816001600160401b0302191690836001600160401b031602179055508a6060013560045f8282546136db91906154d7565b925050819055508060055f8282546136f391906154d7565b90915550613709905060608c0160408d01614e39565b6001600160a01b031661372260408d0160208e01615308565b6001600160801b03191660035f9054906101000a900460801b6001600160801b0319167fddc469e1e78b774ed8fa261ecf2cb0081b304697ade1665e57a5e2d6271343758e60600135868660405161378d939291909283526020830191909152604082015260600190565b60405180910390a46137c96137a860608d0160408e01614e39565b6137b68360608f01356156ad565b6002546001600160a01b03169190612fc0565b5050505050505050505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661108057604051631afcd79f60e31b815260040160405180910390fd5b6138276137d6565b5f80516020615a9e8339815191527fa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d10261386084826158f7565b506003810161386f83826158f7565b505f8082556001909101555050565b5f5f80516020615b1e8339815191526138978484611921565b613916575f848152602082815260408083206001600160a01b03871684529091529020805460ff191660011790556138cc3390565b6001600160a01b0316836001600160a01b0316857f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001915050610998565b5f915050610998565b5092915050565b5f611cb2836001600160a01b0384166140d2565b5f81515f0361394a57505f919050565b61395582600161411e565b91505b6001825111156139745761396d82600161411e565b9150613958565b815f81518110613986576139866152f4565b60200260200101519050919050565b61399f8282611921565b610f1a5760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044016114fa565b80515f906001600160a01b03166139e657505f919050565b60208201516001600160d01b031916657bb7577aaf5760d11b01613a6757815f01516001600160a01b031663fbccedae6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613a43573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061099891906156c0565b60208201516001600160d01b03191665b275294801e560d01b01613aca5781516040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015613a43573d5f803e3d5ffd5b602082015160405163084523c560e11b81526001600160d01b031990911660048201526024016114fa565b5f838302815f1985870982811083820303915050805f03613b2957838281613b1f57613b1f6159b2565b0492505050611cb2565b808411613b495760405163227bc15360e01b815260040160405180910390fd5b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b5f5f80516020615b1e833981519152613bcd8484611921565b15613916575f848152602082815260408083206001600160a01b0387168085529252808320805460ff1916905551339287917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a46001915050610998565b5f611cb2836001600160a01b0384166142be565b5f613c556001600160a01b03841683614398565b905080515f14158015613c79575080806020019051810190613c7791906159c6565b155b1561102b57604051635274afe760e01b81526001600160a01b03841660048201526024016114fa565b5f825f018281548110613cb757613cb76152f4565b905f5260205f200154905092915050565b5f611cb282845f01518560200151613af5565b5f80848611613cea575f613cf4565b613cf485876156ad565b90505f818511613d04575f613d0e565b613d0e82866156ad565b9050612d618185612710613af5565b5f611cb2828460200151855f0151613af5565b5f7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f613d5a6143a5565b613d6261440d565b60408051602081019490945283019190915260608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b5f805f8351604103613dda576020840151604085015160608601515f1a613dcc8882858561444f565b955095509550505050613de5565b505081515f91506002905b9250925092565b5f805f856001600160a01b03168585604051602401613e0c9291906159e1565b60408051601f198184030181529181526020820180516001600160e01b0316630b135d3f60e11b17905251613e4191906159f9565b5f60405180830381855afa9150503d805f8114613e79576040519150601f19603f3d011682016040523d82523d5f602084013e613e7e565b606091505b5091509150818015613e9257506020815110155b80156132e057508051630b135d3f60e11b90613eb790830160209081019084016156c0565b149695505050505050565b5f826003811115613ed557613ed5615781565b03613ede575050565b6001826003811115613ef257613ef2615781565b03613f105760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115613f2457613f24615781565b03613f455760405163fce698f760e01b8152600481018290526024016114fa565b6003826003811115613f5957613f59615781565b03610f1a576040516335e2f38360e21b8152600481018290526024016114fa565b5f81815b84811015611cae57613fa882878784818110613f9c57613f9c6152f4565b90506020020135614517565b9150600101613f7e565b6080828101518051602091820151604080517f953108a3ec009aa6b52fdec87fca4e92a1dd82710c0c6e2497368614711c355f81860152808201939093526060808401929092528051808403830181529483018152845194840194909420865184880151868901519389015160a0808b01517f34a89751a0a9c434a0b09a2df0ebf72338e87f92fc423ec7b07bb6a49af0f704918801919091526001600160801b031993841660c08801529290911660e08601526001600160a01b03909316610100850152610120840192909252610140830181905261016080840192909252845180840390920182526101808301948590528151919093012061190160f01b845261018282018590526101a290910181905260429092205f9290610fef565b5f81815260018301602052604081205461411757508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610998565b505f610998565b81516060905f61412f600283615a14565b90505f61413d600284615a27565b1580159150614154578161415081615a3a565b9250505b858561419f57826001600160401b03811115614172576141726146ae565b60405190808252806020026020018201604052801561419b578160200160208202803683370190505b5090505b5f826141ab57836141b6565b6141b66001856156ad565b90505f5b818110156142445761421f896141d1836002615a52565b815181106141e1576141e16152f4565b60200260200101518a8360026141f79190615a52565b6142029060016154d7565b81518110614212576142126152f4565b6020026020010151614517565b838281518110614231576142316152f4565b60209081029190910101526001016141ba565b5082156142a9576142808861425a6001886156ad565b8151811061426a5761426a6152f4565b60200260200101518960018861420291906156ad565b8261428c6001876156ad565b8151811061429c5761429c6152f4565b6020026020010181815250505b86156142b3578382525b509695505050505050565b5f8181526001830160205260408120548015613916575f6142e06001836156ad565b85549091505f906142f3906001906156ad565b9050808214614352575f865f018281548110614311576143116152f4565b905f5260205f200154905080875f018481548110614331576143316152f4565b5f918252602080832090910192909255918252600188019052604090208390555b855486908061436357614363615a69565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610998565b6060611cb283835f614543565b5f5f80516020615a9e833981519152816143bd613012565b8051909150156143d557805160209091012092915050565b815480156143e4579392505050565b7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470935050505090565b5f5f80516020615a9e833981519152816144256130d2565b80519091501561443d57805160209091012092915050565b600182015480156143e4579392505050565b5f80807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561448857505f9150600390508261450d565b604080515f808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa1580156144d9573d5f803e3d5ffd5b5050604051601f1901519150506001600160a01b03811661450457505f92506001915082905061450d565b92505f91508190505b9450945094915050565b5f818310614531575f828152602084905260409020611cb2565b5f838152602083905260409020611cb2565b6060814710156145685760405163cd78605960e01b81523060048201526024016114fa565b5f80856001600160a01b0316848660405161458391906159f9565b5f6040518083038185875af1925050503d805f81146145bd576040519150601f19603f3d011682016040523d82523d5f602084013e6145c2565b606091505b50915091506132e08683836060826145e2576145dd82614629565b611cb2565b81511580156145f957506001600160a01b0384163b155b1561462257604051639996b31560e01b81526001600160a01b03851660048201526024016114fa565b5080611cb2565b8051156146395780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5080545f825560010160029004905f5260205f209081019061184891905b80821115614683575f8155600101614670565b5090565b5f60208284031215614697575f80fd5b81356001600160e01b031981168114611cb2575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051606081016001600160401b03811182821017156146e4576146e46146ae565b60405290565b60405160a081016001600160401b03811182821017156146e4576146e46146ae565b6040516101c081016001600160401b03811182821017156146e4576146e46146ae565b604051601f8201601f191681016001600160401b0381118282101715614757576147576146ae565b604052919050565b6001600160a01b0381168114611848575f80fd5b803561477e8161475f565b919050565b80356001600160801b03198116811461477e575f80fd5b6001600160d01b031981168114611848575f80fd5b5f606082840312156147bf575f80fd5b6147c76146c2565b905081356147d48161475f565b815260208201356147e48161479a565b602082015260408201356147f78161479a565b604082015292915050565b5f6001600160401b0382111561481a5761481a6146ae565b5060051b60200190565b6001600160401b0381168114611848575f80fd5b8015158114611848575f80fd5b5f60a08284031215614855575f80fd5b61485d6146ea565b905061486882614783565b815260208201356148788161475f565b6020820152604082013561488b81614824565b6040820152606082013561489e81614824565b606082015260808201356148b181614838565b608082015292915050565b5f82601f8301126148cb575f80fd5b813560206148e06148db83614802565b61472f565b8083825260208201915060a0602060a08602880101945087851115614903575f80fd5b602087015b858110156149275761491a8982614845565b8452928401928101614908565b5090979650505050505050565b803561ffff8116811461477e575f80fd5b5f60608284031215614955575f80fd5b61495d6146c2565b905061496882614783565b815260208201356149788161475f565b60208201526147f760408301614934565b5f82601f830112614998575f80fd5b813560206149a86148db83614802565b8083825260208201915060606020606086028801019450878511156149cb575f80fd5b602087015b85811015614927576149e28982614945565b84529284019281016149d0565b5f602082840312156149ff575f80fd5b81356001600160401b0380821115614a15575f80fd5b908301906102008286031215614a29575f80fd5b614a3161470c565b614a3a83614773565b8152614a4860208401614783565b6020820152614a5a86604085016147af565b6040820152614a6b60a08401614773565b606082015260c083013582811115614a81575f80fd5b614a8d878286016148bc565b60808301525060e083013582811115614aa4575f80fd5b614ab087828601614989565b60a0830152506101009150614ac6828401614773565b60c0820152610120614ad9818501614773565b60e0830152610140614aec818601614773565b848401526101609350614b00848601614773565b828401526101809150614b14828601614773565b908301526101a0614b26858201614773565b848401526101c085013582840152614b416101e08601614934565b908301525095945050505050565b5f60208284031215614b5f575f80fd5b5035919050565b5f8083601f840112614b76575f80fd5b5081356001600160401b03811115614b8c575f80fd5b6020830191508360208260051b8501011115614ba6575f80fd5b9250929050565b5f8060208385031215614bbe575f80fd5b82356001600160401b03811115614bd3575f80fd5b614bdf85828601614b66565b90969095509350505050565b5f815180845260208085019450602084015f5b83811015614c1a57815187529582019590820190600101614bfe565b509495945050505050565b602081525f611cb26020830184614beb565b5f8060408385031215614c48575f80fd5b823591506020830135614c5a8161475f565b809150509250929050565b5f805f60408486031215614c77575f80fd5b83356001600160401b0380821115614c8d575f80fd5b818601915086601f830112614ca0575f80fd5b813581811115614cae575f80fd5b87602060a083028501011115614cc2575f80fd5b6020928301989097509590910135949350505050565b5f60208284031215614ce8575f80fd5b8135611cb281614838565b5f805f805f60608688031215614d07575f80fd5b85356001600160401b0380821115614d1d575f80fd5b614d2989838a01614b66565b90975095506020880135915080821115614d41575f80fd5b50614d4e88828901614b66565b9094509250506040860135614d6281614838565b809150509295509295909350565b5f8083601f840112614d80575f80fd5b5081356001600160401b03811115614d96575f80fd5b602083019150836020606083028501011115614ba6575f80fd5b5f8060208385031215614dc1575f80fd5b82356001600160401b03811115614dd6575f80fd5b614bdf85828601614d70565b602080825282518282018190525f919060409081850190868401855b82811015614e2c578151805185528601516001600160401b0316868501529284019290850190600101614dfe565b5091979650505050505050565b5f60208284031215614e49575f80fd5b8135611cb28161475f565b5f805f60608486031215614e66575f80fd5b8335614e718161475f565b92506020840135614e818161475f565b929592945050506040919091013590565b5f60608284031215614ea2575f80fd5b50919050565b602080825282518282018190525f919060409081850190868401855b82811015614e2c57815180516001600160a01b0316855286015161ffff16868501529284019290850190600101614ec4565b5f5b83811015614f10578181015183820152602001614ef8565b50505f910152565b5f8151808452614f2f816020860160208601614ef6565b601f01601f19169290920160200192915050565b60ff60f81b8816815260e060208201525f614f6160e0830189614f18565b8281036040840152614f738189614f18565b606084018890526001600160a01b038716608085015260a0840186905283810360c08501529050614fa48185614beb565b9a9950505050505050505050565b5f8060408385031215614fc3575f80fd5b50508035926020909101359150565b602080825282518282018190525f9190848201906040850190845b818110156150135783516001600160801b03191683529284019291840191600101614fed565b50909695505050505050565b5f805f60608486031215615031575f80fd5b505081359360208301359350604090920135919050565b5f805f838503606081121561505b575f80fd5b84356001600160401b0380821115615071575f80fd5b818701915087601f830112615084575f80fd5b813581811115615092575f80fd5b8860208260071b85010111156150a6575f80fd5b6020929092019550909350506040601f19820112156150c3575f80fd5b506020840190509250925092565b5f602082840312156150e1575f80fd5b611cb282614934565b5f80602083850312156150fb575f80fd5b82356001600160401b0380821115615111575f80fd5b818501915085601f830112615124575f80fd5b813581811115615132575f80fd5b8660208260061b8501011115615146575f80fd5b60209290920196919550909350505050565b5f60a08284031215614ea2575f80fd5b5f8083601f840112615178575f80fd5b5081356001600160401b0381111561518e575f80fd5b602083019150836020828501011115614ba6575f80fd5b5f805f805f60e086880312156151b9575f80fd5b6151c38787615158565b945060a08601356001600160401b03808211156151de575f80fd5b6151ea89838a01615168565b909650945060c0880135915080821115615202575f80fd5b5061520f88828901615168565b969995985093965092949392505050565b5f805f805f805f805f898b0361020081121561523a575f80fd5b60e0811215615247575f80fd5b5089985060e08a01356001600160401b0380821115615264575f80fd5b6152708d838e01615168565b909a5098506101008c0135915080821115615289575f80fd5b6152958d838e01615168565b90985096508691506152ab8d6101208e01615158565b95506101c08c01359150808211156152c1575f80fd5b506152ce8c828d01614b66565b9094509250506101e08a01356152e381614838565b809150509295985092959850929598565b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215615318575f80fd5b611cb282614783565b5f60a08284031215615331575f80fd5b611cb28383614845565b5f6020828403121561534b575f80fd5b8135611cb281614824565b5f60608284031215615366575f80fd5b611cb28383614945565b5f60608284031215615380575f80fd5b611cb283836147af565b81356153958161475f565b81546001600160a01b031981166001600160a01b0392909216918217835560208401356153c18161479a565b65ffffffffffff60a01b60309190911c166001600160d01b03199182168317811784556040850135916153f38361479a565b9217911617905550565b60608101823561540c8161475f565b6001600160a01b0316825260208301356154258161479a565b6001600160d01b031990811660208401526040840135906154458261479a565b8082166040850152505092915050565b60408152602460408201527f736574556e6c6f636b65722828616464726573732c6279746573362c627974656060820152637336292960e01b608082015260a060208201525f611cb260a0830184614f18565b5f602082840312156154b8575f80fd5b8151611cb28161475f565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610998576109986154c3565b8135815560018101602083013561550081614824565b815467ffffffffffffffff19166001600160401b03919091161790555050565b61ffff82811682821603908082111561391f5761391f6154c3565b61ffff81811683821601908082111561391f5761391f6154c3565b5f60a08284031215615566575f80fd5b61556e6146ea565b61557783614783565b815261558560208401614783565b602082015260408301356155988161475f565b6040820152606083810135908201526080928301359281019290925250919050565b6020808252602c908201527f656e74697479555549442063616e6e6f742062652074686520706c6174666f7260408201526b1b48195b9d1a5d1e5555525160a21b606082015260800190565b6001600160401b0381811683821601908082111561391f5761391f6154c3565b606080825284519082018190525f906020906080840190828801845b8281101561565e57815184529284019290840190600101615642565b5050506020840195909552505060400152919050565b60408152601060408201526f736574456e61626c656428626f6f6c2960801b6060820152608060208201525f611cb26080830184614f18565b81810381811115610998576109986154c3565b5f602082840312156156d0575f80fd5b5051919050565b602081525f611cb26020830184614f18565b600181811c908216806156fd57607f821691505b602082108103614ea257634e487b7160e01b5f52602260045260245ffd5b5f6040828403121561572b575f80fd5b604051604081018181106001600160401b038211171561574d5761574d6146ae565b604052823581526020928301359281019290925250919050565b5f60408284031215615777575f80fd5b611cb2838361571b565b634e487b7160e01b5f52602160045260245ffd5b60a081016001600160801b03196157ab84614783565b16825260208301356157bc8161475f565b6001600160a01b0316602083015260408301356157d881614824565b6001600160401b0390811660408401526060840135906157f782614824565b166060830152608083013561580b81614838565b80151560808401525092915050565b5f60e0828403121561582a575f80fd5b60405160c081018181106001600160401b038211171561584c5761584c6146ae565b60405261585883614783565b815261586660208401614783565b602082015260408301356158798161475f565b604082015260608381013590820152615895846080850161571b565b608082015260c0929092013560a083015250919050565b601f82111561102b57805f5260205f20601f840160051c810160208510156158d15750805b601f840160051c820191505b818110156158f0575f81556001016158dd565b5050505050565b81516001600160401b03811115615910576159106146ae565b6159248161591e84546156e9565b846158ac565b602080601f831160018114615957575f84156159405750858301515b5f19600386901b1c1916600185901b178555610d74565b5f85815260208120601f198616915b8281101561598557888601518255948401946001909101908401615966565b50858210156159a257878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b5f52601260045260245ffd5b5f602082840312156159d6575f80fd5b8151611cb281614838565b828152604060208201525f6119196040830184614f18565b5f8251615a0a818460208701614ef6565b9190910192915050565b5f82615a2257615a226159b2565b500490565b5f82615a3557615a356159b2565b500690565b5f60018201615a4b57615a4b6154c3565b5060010190565b8082028115828204841417610998576109986154c3565b634e487b7160e01b5f52603160045260245ffdfec1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000a16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08eb80ee6ccad1a05bacb615631c5c657518a93babef3d070b1c2aa8d8f2d00cbfe2f4eaae4a9751e85a3e4a7b9587827a877f29914755229b07a7b2da98285f7002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b62680063d8e56f0160910d57b83f54cac0b3871607c2529985aa50e353236389f5accaf0d6c3c8ca089b9e67e712dd7b15ff94395328b650078948c3ebdde284f94f6ea2646970667358221220fc04dead98cb336a1645e8b42e60d41ced52eddedc06035d0527211c7d076f3c64736f6c63430008170033aeaff0ba5714de3101330cd09333f32afb2556d1f0ec0469ef94ffe1e27c4bca63d8e56f0160910d57b83f54cac0b3871607c2529985aa50e353236389f5acca000000000000000000000000395426ce9081ae5cea3f9fba3078b00f16e7ae2100000000000000000000000008f6f42c132119a908964989e2126d224ea0bddf00000000000000000000000021f51eb850770f8c4bef6d0a42ce0226e6f92186000000000000000000000000395426ce9081ae5cea3f9fba3078b00f16e7ae21000000000000000000000000395426ce9081ae5cea3f9fba3078b00f16e7ae2100000000000000000000000008f6f42c132119a908964989e2126d224ea0bddf0000000000000000000000009056593d4721e6fbd7b392613ac5d3ea031230f200000000000000000000000008f6f42c132119a908964989e2126d224ea0bddf00000000000000000000000028fbfa68243f58edc39bf6d2200059d97448cc3f00000000000000000000000021f51eb850770f8c4bef6d0a42ce0226e6f92186

Deployed Bytecode

0x608060405234801562000010575f80fd5b50600436106200014c575f3560e01c80638d1cd1e411620000c3578063a8b81ea01162000083578063a8b81ea014620003df578063a8fc9e2914620003f6578063ca15c873146200041e578063d547741f1462000435578063ec87621c146200044c578063f83f55a91462000474575f80fd5b80638d1cd1e414620003495780639010d07c146200039557806391d1485414620003ac5780639cdf7d7414620003c3578063a217fddf14620003d7575f80fd5b806336568abe116200010f57806336568abe146200025457806354fd4d50146200026b5780635ec9a7a014620002f35780636c036fcf146200030a57806370824c5c1462000321575f80fd5b806301ffc9a71462000150578063248a9ca3146200017c57806329061c0514620001b05780632a36a161146200020b5780632f2ff15d146200023b575b5f80fd5b620001676200016136600462000c94565b6200049c565b60405190151581526020015b60405180910390f35b620001a16200018d36600462000cbd565b5f9081526020819052604090206001015490565b60405190815260200162000173565b600254600354600454600554620001d7936001600160a01b03908116938116928116911684565b604080516001600160a01b039586168152938516602085015291841691830191909152909116606082015260800162000173565b620002226200021c36600462001024565b620004c9565b6040516001600160a01b03909116815260200162000173565b620002526200024c36600462001113565b6200061c565b005b620002526200026536600462001113565b6200064a565b6040805163ffffffff7f0000000000000000000000000000000000000000000000000000000000000002811682527f0000000000000000000000000000000000000000000000000000000000000000811660208301527f0000000000000000000000000000000000000000000000000000000000000000169181019190915260600162000173565b620002526200030436600462001144565b62000685565b620002526200031b366004620011d3565b6200070f565b620001a17f797343f8d6a29aafeb3aaf0910a8973e0081c60c2f6c1f775cd9f76ea348fc1e81565b6006546007546008546200036a926001600160a01b03908116928116911683565b604080516001600160a01b039485168152928416602084015292169181019190915260600162000173565b62000222620003a6366004620011f1565b6200075e565b62000167620003bd36600462001113565b6200077e565b60095462000222906001600160a01b031681565b620001a15f81565b62000252620003f036600462001212565b620007a6565b620001a17faeaff0ba5714de3101330cd09333f32afb2556d1f0ec0469ef94ffe1e27c4bca81565b620001a16200042f36600462000cbd565b6200081c565b620002526200044636600462001113565b62000834565b620001a17f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b0881565b620001a17f63d8e56f0160910d57b83f54cac0b3871607c2529985aa50e353236389f5acca81565b5f6001600160e01b03198216635a05180f60e01b1480620004c35750620004c3826200085c565b92915050565b5f7f797343f8d6a29aafeb3aaf0910a8973e0081c60c2f6c1f775cd9f76ea348fc1e620004f68162000892565b600254600954604080516101c08101825286516001600160a01b0390811682526020808901516001600160801b031916908301528783015192820192909252600554821660608083019190915287015160808083019190915287015160a08083019190915293821660c0808301829052600354841660e08401526004548416610100840152600654841661012084015260075484166101408401526008548416610160840152948801516101808301529387015161ffff166101a08201525f93620005c59390921690620008a1565b9050806001600160a01b031684602001516fffffffffffffffffffffffffffffffff19167fc76008eea2b9856c989708eb2d839fd92034836d5e29455a032c4afa6528ad5760405160405180910390a39392505050565b5f82815260208190526040902060010154620006388162000892565b62000644838362000931565b50505050565b6001600160a01b0381163314620006745760405163334bd91960e11b815260040160405180910390fd5b62000680828262000969565b505050565b7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08620006b18162000892565b508051600280546001600160a01b03199081166001600160a01b039384161790915560208301516003805483169184169190911790556040830151600480548316918416919091179055606090920151600580549093169116179055565b7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b086200073b8162000892565b50600980546001600160a01b0319166001600160a01b0392909216919091179055565b5f82815260016020526040812062000777908362000999565b9392505050565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b7f63d8e56f0160910d57b83f54cac0b3871607c2529985aa50e353236389f5acca620007d28162000892565b508051600680546001600160a01b03199081166001600160a01b03938416179091556020830151600780548316918416919091179055604090920151600880549093169116179055565b5f818152600160205260408120620004c390620009a6565b5f82815260208190526040902060010154620008508162000892565b62000644838362000969565b5f6001600160e01b03198216637965db0b60e01b1480620004c357506301ffc9a760e01b6001600160e01b0319831614620004c3565b6200089e8133620009b0565b50565b5f80838563052548e960e01b85604051602401620008c0919062001358565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b0319909416939093179092529051620008ff9062000c86565b6200090d93929190620014ea565b604051809103905ff08015801562000927573d5f803e3d5ffd5b5095945050505050565b5f806200093f8484620009f4565b9050801562000777575f84815260016020526040902062000961908462000a89565b509392505050565b5f8062000977848462000a9f565b9050801562000777575f84815260016020526040902062000961908462000b0c565b5f62000777838362000b22565b5f620004c3825490565b620009bc82826200077e565b620009f05760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440160405180910390fd5b5050565b5f62000a0183836200077e565b62000a81575f838152602081815260408083206001600160a01b03861684529091529020805460ff1916600117905562000a383390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001620004c3565b505f620004c3565b5f62000777836001600160a01b03841662000b4b565b5f62000aac83836200077e565b1562000a81575f838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001620004c3565b5f62000777836001600160a01b03841662000b92565b5f825f01828154811062000b3a5762000b3a62001554565b905f5260205f200154905092915050565b5f81815260018301602052604081205462000a8157508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155620004c3565b5f818152600183016020526040812054801562000c7c575f62000bb760018362001568565b85549091505f9062000bcc9060019062001568565b905080821462000c32575f865f01828154811062000bee5762000bee62001554565b905f5260205f200154905080875f01848154811062000c115762000c1162001554565b5f918252602080832090910192909255918252600188019052604090208390555b855486908062000c465762000c4662001588565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050620004c3565b5f915050620004c3565b610e50806200159d83390190565b5f6020828403121562000ca5575f80fd5b81356001600160e01b03198116811462000777575f80fd5b5f6020828403121562000cce575f80fd5b5035919050565b634e487b7160e01b5f52604160045260245ffd5b6040516060810167ffffffffffffffff8111828210171562000d0f5762000d0f62000cd5565b60405290565b60405160a0810167ffffffffffffffff8111828210171562000d0f5762000d0f62000cd5565b60405160e0810167ffffffffffffffff8111828210171562000d0f5762000d0f62000cd5565b604051601f8201601f1916810167ffffffffffffffff8111828210171562000d8d5762000d8d62000cd5565b604052919050565b6001600160a01b03811681146200089e575f80fd5b803562000db78162000d95565b919050565b80356001600160801b03198116811462000db7575f80fd5b80356001600160d01b03198116811462000db7575f80fd5b5f6060828403121562000dfd575f80fd5b62000e0762000ce9565b9050813562000e168162000d95565b815262000e266020830162000dd4565b602082015262000e396040830162000dd4565b604082015292915050565b5f67ffffffffffffffff82111562000e605762000e6062000cd5565b5060051b60200190565b803567ffffffffffffffff8116811462000db7575f80fd5b5f82601f83011262000e92575f80fd5b8135602062000eab62000ea58362000e44565b62000d61565b82815260a0928302850182019282820191908785111562000eca575f80fd5b8387015b8581101562000f5c5781818a03121562000ee6575f80fd5b62000ef062000d15565b62000efb8262000dbc565b81528582013562000f0c8162000d95565b81870152604062000f1f83820162000e6a565b90820152606062000f3283820162000e6a565b90820152608082810135801515811462000f4a575f80fd5b90820152845292840192810162000ece565b5090979650505050505050565b803561ffff8116811462000db7575f80fd5b5f82601f83011262000f8b575f80fd5b8135602062000f9e62000ea58362000e44565b8281526060928302850182019282820191908785111562000fbd575f80fd5b8387015b8581101562000f5c5781818a03121562000fd9575f80fd5b62000fe362000ce9565b62000fee8262000dbc565b81528582013562000fff8162000d95565b8187015260406200101283820162000f69565b90820152845292840192810162000fc1565b5f6020828403121562001035575f80fd5b813567ffffffffffffffff808211156200104d575f80fd5b90830190610120828603121562001062575f80fd5b6200106c62000d3b565b620010778362000daa565b8152620010876020840162000dbc565b60208201526200109b866040850162000dec565b604082015260a083013582811115620010b2575f80fd5b620010c08782860162000e82565b60608301525060c083013582811115620010d8575f80fd5b620010e68782860162000f7b565b60808301525060e083013560a082015262001105610100840162000f69565b60c082015295945050505050565b5f806040838503121562001125575f80fd5b823591506020830135620011398162000d95565b809150509250929050565b5f6080828403121562001155575f80fd5b6040516080810181811067ffffffffffffffff821117156200117b576200117b62000cd5565b60405282356200118b8162000d95565b815260208301356200119d8162000d95565b60208201526040830135620011b28162000d95565b60408201526060830135620011c78162000d95565b60608201529392505050565b5f60208284031215620011e4575f80fd5b8135620007778162000d95565b5f806040838503121562001203575f80fd5b50508035926020909101359150565b5f6060828403121562001223575f80fd5b6200122d62000ce9565b82356200123a8162000d95565b815260208301356200124c8162000d95565b60208201526040830135620012618162000d95565b60408201529392505050565b5f815180845260208085019450602084015f5b83811015620012ef57815180516001600160801b0319168852838101516001600160a01b03168489015260408082015167ffffffffffffffff908116918a01919091526060808301519091169089015260809081015115159088015260a0909601959082019060010162001280565b509495945050505050565b5f815180845260208085019450602084015f5b83811015620012ef57815180516001600160801b0319168852838101516001600160a01b03168489015260409081015161ffff1690880152606090960195908201906001016200130d565b60208152620013736020820183516001600160a01b03169052565b5f60208301516200139060408401826001600160801b0319169052565b5060408381015180516001600160a01b0316606085015260208101516001600160d01b031990811660808601529181015190911660a08401525060608301516001600160a01b03811660c08401525060808301516102008060e0850152620013fd6102208501836200126d565b915060a0850151610100601f1986850301818701526200141e8483620012fa565b935060c087015191506101206200143f818801846001600160a01b03169052565b60e088015192506101406200145e818901856001600160a01b03169052565b918801519250610160916200147d888401856001600160a01b03169052565b908801519250610180906200149c888301856001600160a01b03169052565b88015192506101a0620014b9888201856001600160a01b03169052565b918801516001600160a01b03166101c08801528701516101e0870152959095015161ffff1693019290925250919050565b5f60018060a01b0380861683526020818616602085015260606040850152845191508160608501525f5b82811015620015325785810182015185820160800152810162001514565b50505f608082850101526080601f19601f830116840101915050949350505050565b634e487b7160e01b5f52603260045260245ffd5b81810381811115620004c357634e487b7160e01b5f52601160045260245ffd5b634e487b7160e01b5f52603160045260245ffdfe60a060405260405162000e5038038062000e508339810160408190526200002691620003bc565b828162000034828262000099565b50508160405162000045906200035a565b6001600160a01b039091168152602001604051809103905ff0801580156200006f573d5f803e3d5ffd5b506001600160a01b0316608052620000906200008a60805190565b620000fe565b505050620004b3565b620000a4826200016f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2805115620000f057620000eb8282620001ee565b505050565b620000fa62000267565b5050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200013f5f8051602062000e30833981519152546001600160a01b031690565b604080516001600160a01b03928316815291841660208301520160405180910390a16200016c8162000289565b50565b806001600160a01b03163b5f03620001aa57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b80546001600160a01b0319166001600160a01b039290921691909117905550565b60605f80846001600160a01b0316846040516200020c919062000496565b5f60405180830381855af49150503d805f811462000246576040519150601f19603f3d011682016040523d82523d5f602084013e6200024b565b606091505b5090925090506200025e858383620002ca565b95945050505050565b3415620002875760405163b398979f60e01b815260040160405180910390fd5b565b6001600160a01b038116620002b457604051633173bdd160e11b81525f6004820152602401620001a1565b805f8051602062000e30833981519152620001cd565b606082620002e357620002dd8262000330565b62000329565b8151158015620002fb57506001600160a01b0384163b155b156200032657604051639996b31560e01b81526001600160a01b0385166004820152602401620001a1565b50805b9392505050565b805115620003415780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6104fc806200093483390190565b80516001600160a01b03811681146200037f575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f5b83811015620003b45781810151838201526020016200039a565b50505f910152565b5f805f60608486031215620003cf575f80fd5b620003da8462000368565b9250620003ea6020850162000368565b60408501519092506001600160401b038082111562000407575f80fd5b818601915086601f8301126200041b575f80fd5b81518181111562000430576200043062000384565b604051601f8201601f19908116603f011681019083821181831017156200045b576200045b62000384565b8160405282815289602084870101111562000474575f80fd5b6200048783602083016020880162000398565b80955050505050509250925092565b5f8251620004a981846020870162000398565b9190910192915050565b608051610469620004cb5f395f601001526104695ff3fe608060405261000c61000e565b005b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316330361007a575f356001600160e01b03191663278f794360e11b14610070576040516334ad5dbb60e21b815260040160405180910390fd5b610078610082565b565b6100786100b0565b5f806100913660048184610303565b81019061009e919061033e565b915091506100ac82826100c0565b5050565b6100786100bb61011a565b610151565b6100c98261016f565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156101125761010d82826101ea565b505050565b6100ac61025c565b5f61014c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b365f80375f80365f845af43d5f803e80801561016b573d5ff35b3d5ffd5b806001600160a01b03163b5f036101a957604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b0316846040516102069190610407565b5f60405180830381855af49150503d805f811461023e576040519150601f19603f3d011682016040523d82523d5f602084013e610243565b606091505b509150915061025385838361027b565b95945050505050565b34156100785760405163b398979f60e01b815260040160405180910390fd5b6060826102905761028b826102da565b6102d3565b81511580156102a757506001600160a01b0384163b155b156102d057604051639996b31560e01b81526001600160a01b03851660048201526024016101a0565b50805b9392505050565b8051156102ea5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b5f8085851115610311575f80fd5b8386111561031d575f80fd5b5050820193919092039150565b634e487b7160e01b5f52604160045260245ffd5b5f806040838503121561034f575f80fd5b82356001600160a01b0381168114610365575f80fd5b9150602083013567ffffffffffffffff80821115610381575f80fd5b818501915085601f830112610394575f80fd5b8135818111156103a6576103a661032a565b604051601f8201601f19908116603f011681019083821181831017156103ce576103ce61032a565b816040528281528860208487010111156103e6575f80fd5b826020860160208301375f6020848301015280955050505050509250929050565b5f82515f5b81811015610426576020818601810151858301520161040c565b505f92019182525091905056fea2646970667358221220740d83b0f0314c5a4b4f3771cc54601255c45b2e55a7df3cdfd8149f584102c864736f6c63430008170033608060405234801561000f575f80fd5b506040516104fc3803806104fc83398101604081905261002e916100bb565b806001600160a01b03811661005c57604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b6100658161006c565b50506100e8565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f602082840312156100cb575f80fd5b81516001600160a01b03811681146100e1575f80fd5b9392505050565b610407806100f55f395ff3fe608060405260043610610049575f3560e01c8063715018a61461004d5780638da5cb5b146100635780639623609d1461008e578063ad3cb1cc146100a1578063f2fde38b146100de575b5f80fd5b348015610058575f80fd5b506100616100fd565b005b34801561006e575f80fd5b505f546040516001600160a01b0390911681526020015b60405180910390f35b61006161009c366004610260565b610110565b3480156100ac575f80fd5b506100d1604051806040016040528060058152602001640352e302e360dc1b81525081565b6040516100859190610372565b3480156100e9575f80fd5b506100616100f836600461038b565b61017b565b6101056101bd565b61010e5f6101e9565b565b6101186101bd565b60405163278f794360e11b81526001600160a01b03841690634f1ef28690349061014890869086906004016103a6565b5f604051808303818588803b15801561015f575f80fd5b505af1158015610171573d5f803e3d5ffd5b5050505050505050565b6101836101bd565b6001600160a01b0381166101b157604051631e4fbdf760e01b81525f60048201526024015b60405180910390fd5b6101ba816101e9565b50565b5f546001600160a01b0316331461010e5760405163118cdaa760e01b81523360048201526024016101a8565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146101ba575f80fd5b634e487b7160e01b5f52604160045260245ffd5b5f805f60608486031215610272575f80fd5b833561027d81610238565b9250602084013561028d81610238565b9150604084013567ffffffffffffffff808211156102a9575f80fd5b818601915086601f8301126102bc575f80fd5b8135818111156102ce576102ce61024c565b604051601f8201601f19908116603f011681019083821181831017156102f6576102f661024c565b8160405282815289602084870101111561030e575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f81518084525f5b8181101561035357602081850181015186830182015201610337565b505f602082860101526020601f19601f83011685010191505092915050565b602081525f610384602083018461032f565b9392505050565b5f6020828403121561039b575f80fd5b813561038481610238565b6001600160a01b03831681526040602082018190525f906103c99083018461032f565b94935050505056fea26469706673582212200908d16c57edc2c24f442a05324b350d6ce826315cc6002bcfaa956b1d16717464736f6c63430008170033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103a2646970667358221220f1478fc88a0dc9bfb10bdb82055460989f5a8def8b323865b1d232a095a776ae64736f6c63430008170033

Block Transaction Gas Used Reward
view all blocks ##produced##

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

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