S Price: $0.696923 (-8.59%)

Contract

0x35E72AF2E0245077785472eD4A166C56649Ff0B2

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

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

Contract Source Code Verified (Exact Match)

Contract Name:
ClientsFacet

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 10000 runs

Other Settings:
cancun EvmVersion
File 1 of 9 : ClientsFacet.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

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

import {PausableCheck} from "src/abstract/PausableCheck.sol";
import {IClientsFacet} from "src/interfaces/IClientsFacet.sol";
import {LibOwner} from "src/libraries/LibOwner.sol";
import {LibEvents} from "src/libraries/LibEvents.sol";
import {LibErrors} from "src/libraries/LibErrors.sol";
import {LibClients, ClientData} from "src/libraries/LibClients.sol";

/**
 * @title ClientsFacet
 * @dev Contract that provides functionality to manage clients and allow them to manage their projects.
 */
contract ClientsFacet is PausableCheck, IClientsFacet {
    /// @inheritdoc IClientsFacet
    function createClient(address clientOwner, uint128 reservedProjects, bytes32 clientName) external {
        LibOwner.onlyOwner();
        LibClients.ClientsStorage storage clientStorage = LibClients._getClientsStorage();
        require(reservedProjects > 0, LibErrors.ReservedProjectsIsZero());
        require(clientName != bytes32(0), LibErrors.ClientNameEmpty());
        require(clientStorage.isClientNameTaken[clientName] == false, LibErrors.ClientNameTaken());
        uint128 minProjectId = SafeCast.toUint128(clientStorage.lastProjectId + 1);
        uint128 maxProjectId = minProjectId + reservedProjects - 1;
        clientStorage.ownerToClientData[clientOwner] =
            ClientData({minProjectId: minProjectId, maxProjectId: maxProjectId, clientName: clientName});
        clientStorage.lastProjectId = maxProjectId;
        clientStorage.isClientNameTaken[clientName] = true;
        emit LibEvents.NewProjectIds(clientOwner, minProjectId, maxProjectId);
    }

    /// @inheritdoc IClientsFacet
    function transferClientOwnership(address newClientOwner) external notPaused {
        LibClients.ClientsStorage storage clientStorage = LibClients._getClientsStorage();
        require(clientStorage.ownerToClientData[newClientOwner].minProjectId == 0, LibErrors.ClientOwnerReserved());
        ClientData memory clientData = clientStorage.ownerToClientData[msg.sender];
        require(clientData.minProjectId > 0, LibErrors.NotClientOwner());
        delete clientStorage.ownerToClientData[msg.sender];
        clientStorage.ownerToClientData[newClientOwner] = clientData;
        emit LibEvents.ClientOwnershipTransfer(clientData.clientName, msg.sender, newClientOwner);
    }

    /// @inheritdoc IClientsFacet
    function activateProject(uint256 projectId) external notPaused {
        LibClients.ClientsStorage storage clientStorage = LibClients._getClientsStorage();
        ClientData memory clientData = clientStorage.ownerToClientData[msg.sender];
        require(clientData.minProjectId > 0, LibErrors.NotClientOwner());
        require(
            clientData.minProjectId <= projectId && clientData.maxProjectId >= projectId,
            LibErrors.OutOfBoundProjectId()
        );
        require(clientStorage.projectIdActive[projectId] == false, LibErrors.ProjectActive());
        clientStorage.projectIdActive[projectId] = true;
        clientStorage.projectIdToClientName[projectId] = clientData.clientName;
        emit LibEvents.ProjectActivated(projectId);
    }

    /// @inheritdoc IClientsFacet
    function lastProjectId() external view returns (uint256) {
        LibClients.ClientsStorage storage clientStorage = LibClients._getClientsStorage();
        return clientStorage.lastProjectId;
    }

    /// @inheritdoc IClientsFacet
    function isClientNameTaken(bytes32 clientName) external view returns (bool) {
        LibClients.ClientsStorage storage clientStorage = LibClients._getClientsStorage();
        return clientStorage.isClientNameTaken[clientName];
    }

    /// @inheritdoc IClientsFacet
    function ownerToClientData(address owner) external view returns (ClientData memory) {
        LibClients.ClientsStorage storage clientStorage = LibClients._getClientsStorage();
        return clientStorage.ownerToClientData[owner];
    }

    /// @inheritdoc IClientsFacet
    function projectIdToClientName(uint256 projectId) external view returns (bytes32) {
        LibClients.ClientsStorage storage clientStorage = LibClients._getClientsStorage();
        return clientStorage.projectIdToClientName[projectId];
    }

    /// @inheritdoc IClientsFacet
    function projectIdActive(uint256 projectId) external view returns (bool) {
        return LibClients._isProjectActive(projectId);
    }
}

File 2 of 9 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }

    /**
     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
     */
    function toUint(bool b) internal pure returns (uint256 u) {
        assembly ("memory-safe") {
            u := iszero(iszero(b))
        }
    }
}

File 3 of 9 : PausableCheck.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {LibPausable} from "src/libraries/LibPausable.sol";

/**
 * @title PausableCheck
 * @dev Abstract contract that provides a modifier to check if the function is paused.
 */
abstract contract PausableCheck {
    /**
     * @dev Modifier to make a function callable only if it is not paused.
     */
    modifier notPaused() {
        LibPausable._checkNotPaused();
        _;
    }
}

File 4 of 9 : IClientsFacet.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {ClientData} from "src/libraries/LibClients.sol";

interface IClientsFacet {
    /**
     * @dev Creates a new client with the specified parameters.
     * @param clientOwner The address of the client owner.
     * @param reservedProjects The number of projects reserved for the client.
     * @param clientName The name of the client.
     */
    function createClient(address clientOwner, uint128 reservedProjects, bytes32 clientName) external;

    /**
     * @dev Transfers the ownership of the client to a new owner.
     * @param newClientOwner The address of the new client owner.
     */
    function transferClientOwnership(address newClientOwner) external;

    /**
     * @dev Activates a project for the client.
     * @param projectId The ID of the project to activate.
     */
    function activateProject(uint256 projectId) external;

    /**
     * @dev Returns the last project ID.
     * @return The last project ID.
     */
    function lastProjectId() external view returns (uint256);

    /**
     * @dev Checks if a client name is taken.
     * @param clientName The name of the client.
     * @return True if the client name is taken, false otherwise.
     */
    function isClientNameTaken(bytes32 clientName) external view returns (bool);

    /**
     * @dev Returns the client data for a given owner.
     * @param owner The address of the client owner.
     * @return The client data.
     */
    function ownerToClientData(address owner) external view returns (ClientData memory);

    /**
     * @dev Returns the client name for a given project ID.
     * @param projectId The ID of the project.
     * @return The client name.
     */
    function projectIdToClientName(uint256 projectId) external view returns (bytes32);

    /**
     * @dev Checks if a project ID is active.
     * @param projectId The ID of the project.
     * @return True if the project ID is active, false otherwise.
     */
    function projectIdActive(uint256 projectId) external view returns (bool);
}

File 5 of 9 : LibClients.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

struct ClientData {
    uint128 minProjectId;
    uint128 maxProjectId;
    bytes32 clientName;
}

library LibClients {
    /**
     * @custom:storage-location erc7201:yelay-vault.storage.ClientsFacet
     * @custom:member lastProjectId The last project ID.
     * @custom:member ownerToClientData Mapping from owner address to client data.
     * @custom:member isClientNameTaken Mapping from client name to a boolean indicating if the name is taken.
     * @custom:member projectIdToClientName Mapping from project ID to client name.
     * @custom:member projectIdActive Mapping from project ID to a boolean indicating if the project is active.
     */
    struct ClientsStorage {
        uint256 lastProjectId;
        mapping(address => ClientData) ownerToClientData;
        mapping(bytes32 => bool) isClientNameTaken;
        mapping(uint256 => bytes32) projectIdToClientName;
        mapping(uint256 => bool) projectIdActive;
    }

    // keccak256(abi.encode(uint256(keccak256("yelay-vault.storage.ClientsFacet")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant ClientsStorageLocation = 0x78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134800;

    function _getClientsStorage() internal pure returns (ClientsStorage storage $) {
        assembly {
            $.slot := ClientsStorageLocation
        }
    }

    /**
     * @dev Checks if a project is active.
     * @param projectId The ID of the project.
     * @return True if the project is active, false otherwise.
     */
    function _isProjectActive(uint256 projectId) internal view returns (bool) {
        ClientsStorage storage clientStorage = _getClientsStorage();
        return clientStorage.projectIdActive[projectId];
    }

    /**
     * @dev Checks if two project IDs belong to the same client.
     * @param projectId1 The first project ID.
     * @param projectId2 The second project ID.
     * @return True if both project IDs belong to the same client, false otherwise.
     */
    function _sameClient(uint256 projectId1, uint256 projectId2) internal view returns (bool) {
        ClientsStorage storage clientStorage = _getClientsStorage();
        return clientStorage.projectIdToClientName[projectId1] == clientStorage.projectIdToClientName[projectId2];
    }
}

File 6 of 9 : LibErrors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

library LibErrors {
    // ===================== OwnerFacet ================================
    /**
     * @dev The caller account is not authorized to perform an operation.
     * @param account The address of the unauthorized account.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The function selector is invalid.
     * @param selector The invalid function selector.
     */
    error InvalidSelector(bytes4 selector);

    // ===================== ClientsFacet ================================
    /**
     * @dev The owner address is already used by some client.
     */
    error ClientOwnerReserved();

    /**
     * @dev The caller is not the client owner.
     */
    error NotClientOwner();

    /**
     * @dev The project ID is out of bounds.
     */
    error OutOfBoundProjectId();

    /**
     * @dev The project is already active.
     */
    error ProjectActive();

    /**
     * @dev The client name is empty.
     */
    error ClientNameEmpty();

    /**
     * @dev The client name is empty.
     */
    error ReservedProjectsIsZero();

    /**
     * @dev The client name is already taken.
     */
    error ClientNameTaken();

    // ===================== FundsFacet ================================
    /**
     * @dev The project is inactive.
     */
    error ProjectInactive();

    /**
     * @dev The function can only be called in a view context.
     */
    error OnlyView();

    /**
     * @dev Compounding the underlying asset is forbidden.
     */
    error CompoundUnderlyingForbidden();

    /**
     * @dev Position migration is forbidden.
     */
    error PositionMigrationForbidden();

    /**
     * @dev There is not enough underlying assets in YelayLiteVault to cover redeem.
     */
    error NotEnoughInternalFunds();

    /**
     * @dev Redeem doesn't pass minimum asset amount
     */
    error MinRedeem();

    // ===================== SwapWrapper ================================
    /**
     * @dev The token is not WETH.
     */
    error NotWeth();

    /**
     * @dev No ETH available.
     */
    error NoEth();

    // ===================== ManagementFacet ================================
    /**
     * @dev The assets were not withdrawn from strategy.
     */
    error StrategyNotEmpty();

    /**
     * @dev The strategy is already registered.
     */
    error StrategyRegistered();

    /**
     * @dev The strategy is already active.
     */
    error StrategyActive();

    // ===================== LibPausable ================================
    /**
     * @dev The function is paused.
     * @param selector The function selector that is paused.
     */
    error Paused(bytes4 selector);

    // ===================== Swapper ================================

    /**
     * @notice Used when trying to do a swap via an exchange that is not allowed to execute a swap.
     * @param exchange Exchange used.
     */
    error ExchangeNotAllowed(address exchange);

    /**
     * @notice Used when there is nothing to swap.
     * @param tokenIn The token that was intended to be swapped.
     */
    error NothingToSwap(address tokenIn);

    /**
     * @notice Used when nothing was swapped.
     * @param tokenOut The token that was intended to be received.
     */
    error NothingSwapped(address tokenOut);
}

File 7 of 9 : LibEvents.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

library LibEvents {
    // FundsFacet
    /**
     * @dev Emitted when assets are deposited.
     * @param projectId The ID of the project.
     * @param sender The address of the sender.
     * @param receiver The address of the receiver.
     * @param assets The amount of assets deposited.
     * @param shares The amount of shares minted.
     */
    event Deposit(
        uint256 indexed projectId, address indexed sender, address indexed receiver, uint256 assets, uint256 shares
    );

    /**
     * @dev Emitted when assets are redeemed.
     * @param projectId The ID of the project.
     * @param sender The address of the sender.
     * @param receiver The address of the receiver.
     * @param assets The amount of assets redeemed.
     * @param shares The amount of shares burned.
     */
    event Redeem(
        uint256 indexed projectId, address indexed sender, address indexed receiver, uint256 assets, uint256 shares
    );

    /**
     * @dev Emitted when assets are deposited into a strategy.
     * @param strategy The name of the strategy.
     * @param amount The amount of assets deposited.
     */
    event ManagedDeposit(bytes32 indexed strategy, uint256 amount);

    /**
     * @dev Emitted when assets are withdrawn from a strategy.
     * @param strategy The name of the strategy.
     * @param amount The amount of assets withdrawn.
     */
    event ManagedWithdraw(bytes32 indexed strategy, uint256 amount);

    /**
     * @dev Emitted when interest is accrued.
     * @param newTotalAssets The new total assets value.
     * @param interest The amount of interest accrued.
     * @param feeShares The amount of fee shares minted.
     */
    event AccrueInterest(uint256 newTotalAssets, uint256 interest, uint256 feeShares);

    /**
     * @dev Emitted when the last total assets value is updated.
     * @param lastTotalAssets The updated last total assets value.
     */
    event UpdateLastTotalAssets(uint256 lastTotalAssets);

    /**
     * @dev Emitted when assets are compounded.
     * @param amount The amount of assets compounded.
     */
    event Compounded(uint256 amount);

    /**
     * @dev Emitted when a position is migrated.
     * @param account The address of the account.
     * @param fromProjectId The ID of the project from which the position is migrated.
     * @param toProjectId The ID of the project to which the position is migrated.
     * @param shares The amount of shares migrated.
     */
    event PositionMigrated(
        address indexed account, uint256 indexed fromProjectId, uint256 indexed toProjectId, uint256 shares
    );

    /**
     * @dev Emitted when lastTotalAssetsUpdateInterval is updated.
     * @param newInterval The new interval for updating lastTotalAssets.
     */
    event UpdateLastTotalAssetsUpdateInterval(uint256 newInterval);

    // ManagementFacet
    /**
     * @dev Emitted when the deposit queue is updated.
     */
    event UpdateDepositQueue();

    /**
     * @dev Emitted when the withdraw queue is updated.
     */
    event UpdateWithdrawQueue();

    /**
     * @dev Emitted when a strategy is added.
     * @param strategy The address of the strategy.
     * @param supplement Additional data for the strategy.
     */
    event AddStrategy(address indexed strategy, bytes supplement);

    /**
     * @dev Emitted when a strategy is removed.
     * @param strategy The address of the strategy.
     * @param supplement Additional data for the strategy.
     */
    event RemoveStrategy(address indexed strategy, bytes supplement);

    /**
     * @dev Emitted when a strategy is activate.
     * @param strategy The address of the strategy.
     * @param supplement Additional data for the strategy.
     */
    event ActivateStrategy(address indexed strategy, bytes supplement);

    /**
     * @dev Emitted when a strategy is deactivated.
     * @param strategy The address of the strategy.
     * @param supplement Additional data for the strategy.
     */
    event DeactivateStrategy(address indexed strategy, bytes supplement);

    // ClientsFacet
    /**
     * @dev Emitted when new project IDs are assigned to a client.
     * @param owner The address of the client owner.
     * @param minProjectId The minimum project ID.
     * @param maxProjectId The maximum project ID.
     */
    event NewProjectIds(address indexed owner, uint256 minProjectId, uint256 maxProjectId);

    /**
     * @dev Emitted when project ownership is transferred.
     * @param clientName The name of the client.
     * @param oldOwner The address of the old owner.
     * @param newOwner The address of the new owner.
     */
    event ClientOwnershipTransfer(bytes32 indexed clientName, address indexed oldOwner, address indexed newOwner);

    /**
     * @dev Emitted when a project is activated.
     * @param project The ID of the activated project.
     */
    event ProjectActivated(uint256 indexed project);

    // OwnerFacet
    /**
     * @dev Emitted when the ownership transfer process is started.
     * @param previousOwner The address of the previous owner.
     * @param newOwner The address of the new owner.
     */
    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Emitted when the ownership transfer process is completed.
     * @param previousOwner The address of the previous owner.
     * @param newOwner The address of the new owner.
     */
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Emitted when a function selector is mapped to a facet.
     * @param selector The function selector.
     * @param facet The address of the facet.
     */
    event SelectorToFacetSet(bytes4 indexed selector, address indexed facet);

    // AccessFacet
    /**
     * @dev Emitted when a method is paused or unpaused.
     * @param selector The function selector.
     * @param paused The paused state.
     */
    event PausedChange(bytes4 selector, bool paused);

    // Swapper
    /**
     * @notice Emitted when the exchange allowlist is updated.
     * @param exchange Exchange that was updated.
     * @param isAllowed Whether the exchange is allowed to be used in a swap or not after the update.
     */
    event ExchangeAllowlistUpdated(address indexed exchange, bool isAllowed);
}

File 8 of 9 : LibOwner.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {LibErrors} from "src/libraries/LibErrors.sol";

library LibOwner {
    /**
     * @custom:storage-location erc7201:yelay-vault.storage.OwnerFacet
     * @custom:member owner The owner of the contract.
     * @custom:member pendingOwner The address pending to become the owner.
     * @custom:member selectorToFacet Mapping from selector to facet address.
     */
    struct OwnerStorage {
        address owner;
        address pendingOwner;
        mapping(bytes4 => address) selectorToFacet;
    }

    // keccak256(abi.encode(uint256(keccak256("yelay-vault.storage.OwnerFacet")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant OWNER_STORAGE_LOCATION = 0x52b130868e76fc87849159cef46eb9bb0156aa8877197d318e4437829044d000;

    function _getOwnerStorage() internal pure returns (OwnerStorage storage $) {
        assembly {
            $.slot := OWNER_STORAGE_LOCATION
        }
    }

    /**
     * @dev Reverts if the caller is not the owner.
     */
    function onlyOwner() internal view {
        OwnerStorage storage s = _getOwnerStorage();
        require(s.owner == msg.sender, LibErrors.OwnableUnauthorizedAccount(msg.sender));
    }
}

File 9 of 9 : LibPausable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;

import {LibErrors} from "src/libraries/LibErrors.sol";

library LibPausable {
    /**
     * @custom:storage-location erc7201:yelay-vault.storage.Pausable
     * @custom:member selectorToPaused Mapping from selector to a boolean indicating if the method is paused.
     */
    struct PausableStorage {
        mapping(bytes4 => bool) selectorToPaused;
    }

    // keccak256(abi.encode(uint256(keccak256("yelay-vault.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant PAUSABLE_STORAGE_LOCATION =
        0x63245fb7e3e0d2c2a6b753106e72e074a7694d950994c2caa5065a7b16bdb600;

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

    /**
     * @dev checks that called method is not paused
     */
    function _checkNotPaused() internal view {
        if (_getPausableStorage().selectorToPaused[msg.sig]) revert LibErrors.Paused(msg.sig);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"ClientNameEmpty","type":"error"},{"inputs":[],"name":"ClientNameTaken","type":"error"},{"inputs":[],"name":"ClientOwnerReserved","type":"error"},{"inputs":[],"name":"NotClientOwner","type":"error"},{"inputs":[],"name":"OutOfBoundProjectId","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"Paused","type":"error"},{"inputs":[],"name":"ProjectActive","type":"error"},{"inputs":[],"name":"ReservedProjectsIsZero","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"clientName","type":"bytes32"},{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"ClientOwnershipTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"minProjectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxProjectId","type":"uint256"}],"name":"NewProjectIds","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"project","type":"uint256"}],"name":"ProjectActivated","type":"event"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"activateProject","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"clientOwner","type":"address"},{"internalType":"uint128","name":"reservedProjects","type":"uint128"},{"internalType":"bytes32","name":"clientName","type":"bytes32"}],"name":"createClient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"clientName","type":"bytes32"}],"name":"isClientNameTaken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastProjectId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ownerToClientData","outputs":[{"components":[{"internalType":"uint128","name":"minProjectId","type":"uint128"},{"internalType":"uint128","name":"maxProjectId","type":"uint128"},{"internalType":"bytes32","name":"clientName","type":"bytes32"}],"internalType":"struct ClientData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"projectIdActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"projectIdToClientName","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newClientOwner","type":"address"}],"name":"transferClientOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6080604052348015600e575f5ffd5b50610bfb8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610085575f3560e01c8063cce3de8111610058578063cce3de811461010a578063db33bc5b1461011d578063e50b998b1461020a578063fced3a3c14610248575f5ffd5b80630e9644651461008957806341544a82146100bf578063547fd567146100d457806374fb106c146100e7575b5f5ffd5b7f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134800545b6040519081526020015b60405180910390f35b6100d26100cd366004610a86565b610289565b005b6100d26100e2366004610ac5565b610497565b6100fa6100f5366004610a86565b6106ba565b60405190151581526020016100b6565b6100d2610118366004610b15565b6106f1565b6101d161012b366004610b15565b60408051606080820183525f808352602080840182905292840181905273ffffffffffffffffffffffffffffffffffffffff9490941684527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec1348018252928290208251938401835280546fffffffffffffffffffffffffffffffff80821686527001000000000000000000000000000000009091041691840191909152600101549082015290565b6040805182516fffffffffffffffffffffffffffffffff90811682526020808501519091169082015291810151908201526060016100b6565b6100ac610218366004610a86565b5f9081527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134803602052604090205490565b6100fa610256366004610a86565b5f9081527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134802602052604090205460ff1690565b6102916108e4565b335f9081527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec1348016020908152604091829020825160608101845281546fffffffffffffffffffffffffffffffff8082168084527001000000000000000000000000000000009092041693820193909352600190910154928101929092527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec1348009190610366576040517fa2f4000600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80516fffffffffffffffffffffffffffffffff16831080159061039f57508281602001516fffffffffffffffffffffffffffffffff1610155b6103d5576040517f4d3d7cf600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f83815260048301602052604090205460ff161561041f576040517fad7f7ce800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f838152600483016020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558381015160038601909252808320919091555184917fa24f98fafda171640bd6bc2dfff773d30beccd904d6c386e658a1c79f9e7666391a2505050565b61049f61099d565b7f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec1348006fffffffffffffffffffffffffffffffff8316610509576040517f6cca1dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81610540576040517f835f2c0f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82815260028201602052604090205460ff161561058a576040517fd172356e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80545f906105a29061059d906001610b62565b610a2d565b90505f60016105b18684610b75565b6105bb9190610b9d565b604080516060810182526fffffffffffffffffffffffffffffffff85811680835284821660208085018281528587018c815273ffffffffffffffffffffffffffffffffffffffff8f165f81815260018e810186528a82209951945189167001000000000000000000000000000000000294909816939093178855905196860196909655828b558b815260028b01825286902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909417909355845191825291810191909152929350917fb050641bed68bf65a7be604341add7d9465172ca0ee0c59feae31460fc7c85d3910160405180910390a2505050505050565b5f8181527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134804602052604081205460ff165b92915050565b6106f96108e4565b73ffffffffffffffffffffffffffffffffffffffff81165f9081527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec13480160205260409020547f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134800906fffffffffffffffffffffffffffffffff16156107a8576040517f0d26a66200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260018083016020908152604092839020835160608101855281546fffffffffffffffffffffffffffffffff8082168084527001000000000000000000000000000000009092041693820193909352920154928201929092529061083c576040517fa2f4000600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f818152600180850160209081526040808420848155830184905573ffffffffffffffffffffffffffffffffffffffff88168085528185208751938801516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002941693909317835586820151929093018290555191939290917fecf10bc3df721805459bbd19999751f84d91751706b38778db61795acb9b52269190a4505050565b7f63245fb7e3e0d2c2a6b753106e72e074a7694d950994c2caa5065a7b16bdb6005f80357fffffffff00000000000000000000000000000000000000000000000000000000168152602091909152604090205460ff161561099b576040517fa5ced19b0000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000005f351660048201526024015b60405180910390fd5b565b7f52b130868e76fc87849159cef46eb9bb0156aa8877197d318e4437829044d0008054339073ffffffffffffffffffffffffffffffffffffffff168114610a29576040517f118cdaa700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401610992565b5050565b5f6fffffffffffffffffffffffffffffffff821115610a82576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526080600482015260248101839052604401610992565b5090565b5f60208284031215610a96575f5ffd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610ac0575f5ffd5b919050565b5f5f5f60608486031215610ad7575f5ffd5b610ae084610a9d565b925060208401356fffffffffffffffffffffffffffffffff81168114610b04575f5ffd5b929592945050506040919091013590565b5f60208284031215610b25575f5ffd5b610b2e82610a9d565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b808201808211156106eb576106eb610b35565b6fffffffffffffffffffffffffffffffff81811683821601908111156106eb576106eb610b35565b6fffffffffffffffffffffffffffffffff82811682821603908111156106eb576106eb610b3556fea2646970667358221220ccf4bae83487a011d8444f82082ce3f7e3615ab21959de74102005c1f96e334864736f6c634300081c0033

Deployed Bytecode

0x608060405234801561000f575f5ffd5b5060043610610085575f3560e01c8063cce3de8111610058578063cce3de811461010a578063db33bc5b1461011d578063e50b998b1461020a578063fced3a3c14610248575f5ffd5b80630e9644651461008957806341544a82146100bf578063547fd567146100d457806374fb106c146100e7575b5f5ffd5b7f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134800545b6040519081526020015b60405180910390f35b6100d26100cd366004610a86565b610289565b005b6100d26100e2366004610ac5565b610497565b6100fa6100f5366004610a86565b6106ba565b60405190151581526020016100b6565b6100d2610118366004610b15565b6106f1565b6101d161012b366004610b15565b60408051606080820183525f808352602080840182905292840181905273ffffffffffffffffffffffffffffffffffffffff9490941684527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec1348018252928290208251938401835280546fffffffffffffffffffffffffffffffff80821686527001000000000000000000000000000000009091041691840191909152600101549082015290565b6040805182516fffffffffffffffffffffffffffffffff90811682526020808501519091169082015291810151908201526060016100b6565b6100ac610218366004610a86565b5f9081527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134803602052604090205490565b6100fa610256366004610a86565b5f9081527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134802602052604090205460ff1690565b6102916108e4565b335f9081527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec1348016020908152604091829020825160608101845281546fffffffffffffffffffffffffffffffff8082168084527001000000000000000000000000000000009092041693820193909352600190910154928101929092527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec1348009190610366576040517fa2f4000600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80516fffffffffffffffffffffffffffffffff16831080159061039f57508281602001516fffffffffffffffffffffffffffffffff1610155b6103d5576040517f4d3d7cf600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f83815260048301602052604090205460ff161561041f576040517fad7f7ce800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f838152600483016020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558381015160038601909252808320919091555184917fa24f98fafda171640bd6bc2dfff773d30beccd904d6c386e658a1c79f9e7666391a2505050565b61049f61099d565b7f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec1348006fffffffffffffffffffffffffffffffff8316610509576040517f6cca1dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81610540576040517f835f2c0f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f82815260028201602052604090205460ff161561058a576040517fd172356e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80545f906105a29061059d906001610b62565b610a2d565b90505f60016105b18684610b75565b6105bb9190610b9d565b604080516060810182526fffffffffffffffffffffffffffffffff85811680835284821660208085018281528587018c815273ffffffffffffffffffffffffffffffffffffffff8f165f81815260018e810186528a82209951945189167001000000000000000000000000000000000294909816939093178855905196860196909655828b558b815260028b01825286902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016909417909355845191825291810191909152929350917fb050641bed68bf65a7be604341add7d9465172ca0ee0c59feae31460fc7c85d3910160405180910390a2505050505050565b5f8181527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134804602052604081205460ff165b92915050565b6106f96108e4565b73ffffffffffffffffffffffffffffffffffffffff81165f9081527f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec13480160205260409020547f78b8360ea116a1ac1aaf7d99dc2a2fa96091e5ce27ad9c46aa3a48ffec134800906fffffffffffffffffffffffffffffffff16156107a8576040517f0d26a66200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f90815260018083016020908152604092839020835160608101855281546fffffffffffffffffffffffffffffffff8082168084527001000000000000000000000000000000009092041693820193909352920154928201929092529061083c576040517fa2f4000600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b335f818152600180850160209081526040808420848155830184905573ffffffffffffffffffffffffffffffffffffffff88168085528185208751938801516fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002941693909317835586820151929093018290555191939290917fecf10bc3df721805459bbd19999751f84d91751706b38778db61795acb9b52269190a4505050565b7f63245fb7e3e0d2c2a6b753106e72e074a7694d950994c2caa5065a7b16bdb6005f80357fffffffff00000000000000000000000000000000000000000000000000000000168152602091909152604090205460ff161561099b576040517fa5ced19b0000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000005f351660048201526024015b60405180910390fd5b565b7f52b130868e76fc87849159cef46eb9bb0156aa8877197d318e4437829044d0008054339073ffffffffffffffffffffffffffffffffffffffff168114610a29576040517f118cdaa700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091166004820152602401610992565b5050565b5f6fffffffffffffffffffffffffffffffff821115610a82576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526080600482015260248101839052604401610992565b5090565b5f60208284031215610a96575f5ffd5b5035919050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610ac0575f5ffd5b919050565b5f5f5f60608486031215610ad7575f5ffd5b610ae084610a9d565b925060208401356fffffffffffffffffffffffffffffffff81168114610b04575f5ffd5b929592945050506040919091013590565b5f60208284031215610b25575f5ffd5b610b2e82610a9d565b9392505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b808201808211156106eb576106eb610b35565b6fffffffffffffffffffffffffffffffff81811683821601908111156106eb576106eb610b35565b6fffffffffffffffffffffffffffffffff82811682821603908111156106eb576106eb610b3556fea2646970667358221220ccf4bae83487a011d8444f82082ce3f7e3615ab21959de74102005c1f96e334864736f6c634300081c0033

Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.