Invest4bPresale

Description:

Multi-signature wallet contract requiring multiple confirmations for transaction execution.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "invest4b_presale.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity 0.8.27;\r
\r
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";\r
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";\r
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";\r
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";\r
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";\r
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";\r
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";\r
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";\r
\r
contract Invest4bPresale is\r
    Initializable,\r
    OwnableUpgradeable,\r
    UUPSUpgradeable,\r
    ReentrancyGuardUpgradeable,\r
    PausableUpgradeable\r
{\r
    using SafeERC20Upgradeable for IERC20Upgradeable;\r
\r
    // -----------------------------------------------------------------------\r
    // Constants\r
    // -----------------------------------------------------------------------\r
\r
    uint256 private constant TOKEN_DECIMALS = 18; // sold token decimals\r
    uint256 private constant PRICE_DECIMALS = 18; // USD price decimals (1 USD = 1e18)\r
\r
    // -----------------------------------------------------------------------\r
    // Types\r
    // -----------------------------------------------------------------------\r
\r
    struct Round {\r
        uint256 startTime;       // round start (unix)\r
        uint256 endTime;         // round end (unix)\r
        uint256 priceUsd;        // 1e18 USD per token\r
        uint256 tokenAllocation; // 18 decimals\r
        uint256 tokensSold;      // 18 decimals\r
        uint256 reserveUsed;     // 18 decimals\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Storage\r
    // -----------------------------------------------------------------------\r
\r
    // Accepted stables and the token being sold\r
    IERC20Upgradeable public USDCInterface;\r
    IERC20Upgradeable public USDTInterface;\r
    IERC20Upgradeable public tokenInterface;\r
\r
    // Rounds\r
    Round[] public rounds;\r
    uint256 public currRoundIdx;\r
\r
    // Totals and reserve\r
    uint256 public totalSoldTokens; // 18 decimals\r
    uint256 public reserveTokens;   // 18 decimals (capacity for oversells across rounds)\r
    uint256 public reserveUsed;     // 18 decimals\r
\r
    // Global window\r
    uint256 public presaleStartTime;\r
    uint256 public presaleEndTime;\r
\r
    // USD accounting (36 decimals: token 1e18 * price 1e18)\r
    uint256 public usdRaised;        // 1e36\r
    uint256 public minUsdCost;       // 1e36\r
    uint256 public maxUsdPerUser;    // 1e36\r
\r
    // VIP accounting (separate from rounds/reserve)\r
    uint256 public vipUsdRaised;     // 1e36 total raised via VIP pricing\r
    uint256 public vipUsdCap36;      // 1e36 global cap for VIP purchases\r
    uint256 public vipSoldTokens;    // 18 decimals total tokens sold via VIP pricing\r
\r
    // Per-user accounting\r
    mapping(address => uint256) public userTotalUsdInvested; // 1e36\r
    mapping(address => bool) public approvedForHighInvestment; // bypass maxUsdPerUser\r
\r
    // Roles / endpoints\r
    address public kycWallet;     // approves "high" investments\r
    address public feeReceiver;   // receives USDC/USDT\r
    address public technicalRole; // sets VIP pricing\r
\r
    // VIP pricing (18-decimal price + expiry)\r
    mapping(address => uint256) public vipPriceUsd;    // 1e18 USD per token override\r
    mapping(address => uint256) public vipPriceExpiry; // unix timestamp; price valid while now <= expiry\r
\r
    // Ultra investment gate (optional usage pattern)\r
    mapping(address => bool) public approvedForUltraInvestment;\r
\r
    // -----------------------------------------------------------------------\r
    // Events\r
    // -----------------------------------------------------------------------\r
\r
    event BuyerRegistered(address indexed buyer);\r
    event BulkPurchaseRecorded(address indexed buyer, uint256 amount, uint256 roundIndex, string source);\r
    event BulkPurchasesRecorded(uint256 totalPurchases, uint256 totalAmount, string source);\r
\r
    event KYCWalletUpdated(address indexed oldKycWallet, address indexed newKycWallet);\r
    event FeeReceiverUpdated(address indexed oldFeeReceiver, address indexed newFeeReceiver);\r
    event TechnicalRoleUpdated(address indexed oldTech, address indexed newTech);\r
\r
    event KYCApprovalUpdated(address indexed user, bool approved);\r
    event UltraInvestmentApprovalUpdated(address indexed user, bool approved);\r
\r
    event VipPriceSet(address indexed user, uint256 priceUsd, uint256 validUntil);\r
    event VipPriceCleared(address indexed user);\r
\r
    event ReserveUsed(uint256 roundIndex, uint256 amount, uint256 totalReserveUsed);\r
    event RoundTransitioned(uint256 fromRound, uint256 toRound, uint256 unsoldTokens);\r
\r
    // New events for VIP cap/accounting\r
    event VipPurchaseRecorded(address indexed buyer, uint256 usdCost36, uint256 tokensBought);\r
    event VipCapUpdated(uint256 oldCap36, uint256 newCap36);\r
\r
    // -----------------------------------------------------------------------\r
    // Initialization / Upgrade\r
    // -----------------------------------------------------------------------\r
\r
    constructor() {\r
        _disableInitializers();\r
    }\r
\r
    /**\r
     * @notice Initialize the upgradeable contract.\r
     */\r
    function initialize(\r
        address usdc,\r
        address usdt,\r
        address saleToken,\r
        address kyc,\r
        address fee,\r
        address tech,\r
        uint256 start,\r
        uint256 end,\r
        uint256 minUsd36,\r
        uint256 maxUsd36,\r
        uint256 reserveTokens_\r
    ) external initializer {\r
        __Ownable_init(msg.sender);\r
        __UUPSUpgradeable_init();\r
        __ReentrancyGuard_init();\r
        __Pausable_init();\r
\r
        USDCInterface = IERC20Upgradeable(usdc);\r
        USDTInterface = IERC20Upgradeable(usdt);\r
        tokenInterface = IERC20Upgradeable(saleToken);\r
\r
        kycWallet = kyc;\r
        feeReceiver = fee;\r
        technicalRole = tech;\r
\r
        presaleStartTime = start;\r
        presaleEndTime = end;\r
        minUsdCost = minUsd36;\r
        maxUsdPerUser = maxUsd36;\r
\r
        reserveTokens = reserveTokens_;\r
        currRoundIdx = 0;\r
\r
        // Set default VIP cap to $250,000,000 at 1e36 scale\r
        vipUsdCap36 = 290_697_674 * 10 ** 36;\r
    }\r
\r
    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {\r
        require(newImplementation != address(0), "Invalid implementation");\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Modifiers\r
    // -----------------------------------------------------------------------\r
\r
    modifier presaleEntryGuard() {\r
        require(block.timestamp >= presaleStartTime, "Presale not started");\r
        require(block.timestamp <= presaleEndTime, "Presale ended");\r
        require(rounds.length > 0, "No rounds configured");\r
        _;\r
    }\r
\r
    modifier onlyKYC() {\r
        require(msg.sender == kycWallet, "Only KYC wallet");\r
        _;\r
    }\r
\r
    modifier onlyTechnical() {\r
        require(msg.sender == technicalRole, "Only technical role");\r
        _;\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Buying (USDC / USDT)\r
    // -----------------------------------------------------------------------\r
\r
    function buyWithUSDT(uint256 usdAmount)\r
        external\r
        nonReentrant\r
        presaleEntryGuard\r
        whenNotPaused\r
        returns (bool)\r
    {\r
        _handleStableBuy(USDTInterface, usdAmount);\r
        return true;\r
    }\r
\r
    function buyWithUSDC(uint256 usdAmount)\r
        external\r
        nonReentrant\r
        presaleEntryGuard\r
        whenNotPaused\r
        returns (bool)\r
    {\r
        _handleStableBuy(USDCInterface, usdAmount);\r
        return true;\r
    }\r
\r
    /**\r
     * @dev Core purchase logic for stablecoins.\r
     *\r
     * Math:\r
     *   scale = 10^(TOKEN_DECIMALS + PRICE_DECIMALS - stableDecimals) = 10^(36 - stableDecimals)\r
     *   usdCost36 = usdAmount * scale           // 1e36 USD\r
     *   tokensToBuy = usdCost36 / priceUsd      // -> 18-dec token amount (since priceUsd is 1e18)\r
     */\r
    function _handleStableBuy(IERC20Upgradeable stable, uint256 usdAmount) internal {\r
        _checkAndTransitionRound();\r
\r
        (uint256 priceUsd, bool isVip) = currentPriceFor(msg.sender); // 1e18 USD per token\r
\r
        // Scale buyer amount from stable decimals to 1e36 USD.\r
        uint256 scale = _stableToUsd36Scale(stable);\r
        uint256 usdCost36 = usdAmount * scale;\r
        require(usdCost36 >= minUsdCost, "Below min");\r
\r
        // Per-user limit / approval gates (with optional ultra tier).\r
        uint256 newTotal = userTotalUsdInvested[msg.sender] + usdCost36;\r
        uint256 ultraLimit = 10_000_000 * 10 ** 36; // $10M at 1e36\r
\r
        require(\r
            newTotal <= maxUsdPerUser\r
            || (newTotal < ultraLimit && approvedForHighInvestment[msg.sender])\r
            || (newTotal >= ultraLimit && approvedForUltraInvestment[msg.sender]),\r
            newTotal >= ultraLimit\r
                ? "Above ultra limit: need ultra approval"\r
                : "Above max per user: need high approval"\r
        );\r
\r
        // Compute tokens and ensure inventory BEFORE taking funds.\r
        uint256 tokensToBuy = usdCost36 / priceUsd; // 18 decimals (rounds down)\r
        require(tokensToBuy > 0, "Amount too small");\r
        require(tokenInterface.balanceOf(address(this)) >= tokensToBuy, "Insufficient inventory");\r
\r
        // Pull funds to fee receiver.\r
        stable.safeTransferFrom(msg.sender, feeReceiver, usdAmount);\r
\r
        // Common bookkeeping\r
        usdRaised += usdCost36;\r
        userTotalUsdInvested[msg.sender] = newTotal;\r
        totalSoldTokens += tokensToBuy;\r
\r
        if (isVip) {\r
            // VIP path: does not affect rounds or reserves, but enforces global VIP cap\r
            require(usdCost36 > 11_627_900e36, "Can't buy lower than 10 million.");\r
            require(vipUsdRaised + usdCost36 <= vipUsdCap36, "VIP cap exceeded");\r
            vipUsdRaised += usdCost36;\r
            vipSoldTokens += tokensToBuy;\r
\r
            // Deliver tokens\r
            tokenInterface.safeTransfer(msg.sender, tokensToBuy);\r
\r
            emit VipPurchaseRecorded(msg.sender, usdCost36, tokensToBuy);\r
            emit BuyerRegistered(msg.sender);\r
        } else {\r
            // Standard path: record sale against round/reserve\r
            _recordSale(tokensToBuy);\r
\r
            // Deliver tokens\r
            tokenInterface.safeTransfer(msg.sender, tokensToBuy);\r
\r
            emit BuyerRegistered(msg.sender);\r
        }\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Views / Price helpers\r
    // -----------------------------------------------------------------------\r
\r
    function currentPriceFor(address user) public view returns (uint256 priceUsd, bool isVipActive) {\r
        if (vipPriceUsd[user] > 0 && block.timestamp <= vipPriceExpiry[user]) {\r
            return (vipPriceUsd[user], true);\r
        }\r
        require(currRoundIdx < rounds.length, "No active round");\r
        return (rounds[currRoundIdx].priceUsd, false);\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Internal helpers\r
    // -----------------------------------------------------------------------\r
\r
    function _stableToUsd36Scale(IERC20Upgradeable stable) internal view returns (uint256) {\r
        uint256 dec = IERC20MetadataUpgradeable(address(stable)).decimals();\r
        require(dec <= TOKEN_DECIMALS + PRICE_DECIMALS, "Stable decimals too large"); // <= 36\r
        return 10 ** (TOKEN_DECIMALS + PRICE_DECIMALS - dec);\r
    }\r
\r
    function _recordSale(uint256 amount) internal {\r
        Round storage r = rounds[currRoundIdx];\r
        uint256 remaining = r.tokenAllocation - r.tokensSold;\r
\r
        if (amount <= remaining) {\r
            r.tokensSold += amount;\r
        } else {\r
            uint256 fromReserve = amount - remaining;\r
            require(reserveUsed + fromReserve <= reserveTokens, "Reserve low");\r
            r.tokensSold += remaining;\r
            r.reserveUsed += fromReserve;\r
            reserveUsed += fromReserve;\r
            emit ReserveUsed(currRoundIdx, fromReserve, reserveUsed);\r
        }\r
    }\r
\r
    function _checkAndTransitionRound() internal {\r
        require(currRoundIdx < rounds.length, "All rounds done");\r
\r
        while (currRoundIdx < rounds.length) {\r
            Round storage r = rounds[currRoundIdx];\r
            if (block.timestamp > r.endTime && currRoundIdx + 1 < rounds.length) {\r
                uint256 unsold = r.tokenAllocation - r.tokensSold;\r
                if (unsold > 0) {\r
                    rounds[currRoundIdx + 1].tokenAllocation += unsold;\r
                    emit RoundTransitioned(currRoundIdx, currRoundIdx + 1, unsold);\r
                }\r
                currRoundIdx++;\r
            } else {\r
                break;\r
            }\r
        }\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Admin: Presale configuration (owner)\r
    // -----------------------------------------------------------------------\r
\r
    function addRound(\r
        uint256 startTime,\r
        uint256 endTime,\r
        uint256 priceUsd,\r
        uint256 tokenAllocation\r
    ) external onlyOwner {\r
        require(startTime < endTime, "Bad round time");\r
        rounds.push(\r
            Round({\r
                startTime: startTime,\r
                endTime: endTime,\r
                priceUsd: priceUsd,\r
                tokenAllocation: tokenAllocation,\r
                tokensSold: 0,\r
                reserveUsed: 0\r
            })\r
        );\r
    }\r
\r
    function configurePresale(\r
        uint256 start,\r
        uint256 end,\r
        uint256 minUsd36,\r
        uint256 maxUsd36,\r
        Round[] calldata roundsInput\r
    ) external onlyOwner {\r
        require(start < end, "Bad times");\r
\r
        presaleStartTime = start;\r
        presaleEndTime = end;\r
        minUsdCost = minUsd36;\r
        maxUsdPerUser = maxUsd36;\r
\r
        delete rounds;\r
        for (uint256 i = 0; i < roundsInput.length; i++) {\r
            require(roundsInput[i].startTime < roundsInput[i].endTime, "Bad round time");\r
            rounds.push(\r
                Round({\r
                    startTime: roundsInput[i].startTime,\r
                    endTime: roundsInput[i].endTime,\r
                    priceUsd: roundsInput[i].priceUsd,\r
                    tokenAllocation: roundsInput[i].tokenAllocation,\r
                    tokensSold: 0,\r
                    reserveUsed: 0\r
                })\r
            );\r
        }\r
        currRoundIdx = 0;\r
    }\r
\r
    function updateRound(\r
        uint256 index,\r
        uint256 start,\r
        uint256 end,\r
        uint256 priceUsd,\r
        uint256 allocation\r
    ) external onlyOwner {\r
        require(index < rounds.length, "Invalid round");\r
        require(start < end, "Bad times");\r
        Round storage r = rounds[index];\r
        require(block.timestamp < r.startTime, "Round already active");\r
        r.startTime = start;\r
        r.endTime = end;\r
        r.priceUsd = priceUsd;\r
        r.tokenAllocation = allocation;\r
    }\r
\r
    function extendPresaleEndTime(uint256 newEnd) external onlyOwner {\r
        presaleEndTime = newEnd;\r
    }\r
\r
    function setStartTime(uint256 newStart) external onlyOwner {\r
        presaleStartTime = newStart;\r
    }\r
\r
    function setReserveTokens(uint256 amount) external onlyOwner {\r
        reserveTokens = amount;\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Admin: Roles & approvals\r
    // -----------------------------------------------------------------------\r
\r
    function setUserApprovedForUltraInvestment(address user, bool approved) external onlyTechnical {\r
        approvedForUltraInvestment[user] = approved;\r
        emit UltraInvestmentApprovalUpdated(user, approved);\r
    }\r
\r
    function setUserApprovedForHighInvestment(address user, bool approved) external onlyKYC {\r
        approvedForHighInvestment[user] = approved;\r
        emit KYCApprovalUpdated(user, approved);\r
    }\r
\r
    function setTechnicalRole(address _new) external onlyOwner {\r
        emit TechnicalRoleUpdated(technicalRole, _new);\r
        technicalRole = _new;\r
    }\r
\r
    function setKYCWallet(address _kyc) external onlyOwner {\r
        emit KYCWalletUpdated(kycWallet, _kyc);\r
        kycWallet = _kyc;\r
    }\r
\r
    function setFeeReceiver(address _new) external onlyOwner {\r
        emit FeeReceiverUpdated(feeReceiver, _new);\r
        feeReceiver = _new;\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Admin: VIP pricing (technical role)\r
    // -----------------------------------------------------------------------\r
\r
    function setVipPrice(address user, uint256 priceUsd, uint256 validUntil) external onlyTechnical {\r
        require(user != address(0), "Zero user");\r
        require(priceUsd > 0, "Zero price");\r
        require(validUntil > block.timestamp, "Expiry not in future");\r
        vipPriceUsd[user] = priceUsd;\r
        vipPriceExpiry[user] = validUntil;\r
        emit VipPriceSet(user, priceUsd, validUntil);\r
    }\r
\r
    function clearVipPrice(address user) external onlyTechnical {\r
        vipPriceUsd[user] = 0;\r
        vipPriceExpiry[user] = 0;\r
        emit VipPriceCleared(user);\r
    }\r
\r
    /**\r
     * @notice Owner can adjust the global VIP cap (1e36 USD units).\r
     */\r
    function setVipUsdCap36(uint256 newCap36) external onlyOwner {\r
        uint256 old = vipUsdCap36;\r
        vipUsdCap36 = newCap36;\r
        emit VipCapUpdated(old, newCap36);\r
    }\r
\r
    // -----------------------------------------------------------------------\r
    // Withdraw / Pause\r
    // -----------------------------------------------------------------------\r
\r
    function withdraw(address _token) external onlyOwner {\r
        uint256 bal;\r
        if (_token == address(0)) {\r
            bal = address(this).balance;\r
            require(bal > 0, "No ETH");\r
            (bool ok, ) = payable(owner()).call{value: bal}("");\r
            require(ok, "Send fail");\r
        } else {\r
            IERC20Upgradeable t = IERC20Upgradeable(_token);\r
            bal = t.balanceOf(address(this));\r
            require(bal > 0, "No tokens");\r
            t.safeTransfer(owner(), bal);\r
        }\r
    }\r
\r
    function pause() external onlyOwner {\r
        _pause();\r
    }\r
\r
    function unpause() external onlyOwner {\r
        _unpause();\r
    }\r
}\r
"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.22;

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

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

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

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

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

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

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

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

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

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

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

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

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

    /**
     * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
     *
     * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
     * is expected to be the implementation slot in ERC-1967.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
        try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
            if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
                revert UUPSUnsupportedProxiableUUID(slot);
            }
            ERC1967Utils.upgradeToAndCall(newImplementation, data);
        } catch {
            // The implementation is not UUPS
            revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
        }
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

    /**
     * @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(IERC20Upgradeable token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, 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(IERC20Upgradeable token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    /**
     * @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(IERC20Upgradeable token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @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(IERC20Upgradeable token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20PermitUpgradeable token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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(IERC20Upgradeable token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

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

    /**
     * @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(IERC20Upgradeable 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))) && AddressUpgradeable.isContract(address(token));
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

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

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}
"
    },
    "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable
    struct OwnableStorage {
        address _owner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
        assembly {
            $.slot := OwnableStorageLocation
        }
    }

    /**
     * @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.
     */
    function __Ownable_init(address initialOwner) internal onlyInitializing {
        __Ownable_init_unchained(initialOwner);
    }

    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
        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) {
        OwnableStorage storage $ = _getOwnableStorage();
        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 {
        OwnableStorage storage $ = _getOwnableStorage();
        address oldOwner = $._owner;
        $._owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

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

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

    bool private _paused;

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

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

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}
"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

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

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}
"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// 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
        }
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string mem

Tags:
ERC20, Multisig, Pausable, Upgradeable, Multi-Signature, Factory|addr:0x378dee55da7619a349bd2e205767a137d17577af|verified:true|block:23690051|tx:0x0d8112ad38228d4fc1f8f89ebfee790ac006c8d76039d081d35cfea2d25ab2df|first_check:1761831167

Submitted on: 2025-10-30 14:32:50

Comments

Log in to comment.

No comments yet.