Skip to content
Verified contractPartial

CommandsModule

Address0x95c11a44c58bac780c8138f59e7bc5f3fd7f4fb1
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 200 runs
EVM version
prague
License
Not stated
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,420,632
Creation transaction
0xaf26047b3f…a5ee278323

dependencies/diamond-router-V1/src/modules/CommandsModule.sol

pragma solidity ^0.8.20;

import {IExecutor} from "src/interfaces/IExecutor.sol";
import {LibModuleManager} from "src/modules/libraries/LibModuleManager.sol";
import {LibExecutionModule} from "src/modules/libraries/LibExecutionModule.sol";
import {ICommandManager, ICommand} from "src/interfaces/ICommandManager.sol";
import {LibModuleManager} from "src/modules/libraries/LibModuleManager.sol";
import {AccessManagedUpgradeable} from "openzeppelin-contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";

contract CommandsModule is IExecutor, ICommandManager, AccessManagedUpgradeable {

    /// @notice Add/replace/remove any number of functions and optionally execute
    ///         a function with delegatecall
    /// @param _commandModifications Array of implementation addresses, actions, commands,
    ///                                     and function selectors
    /// @param _init The address of the contract or facet to execute _calldata
    /// @param _calldata A function call executed with delegatecall on _init
    function manageCommands(
        ICommand.CommandModification[] memory _commandModifications,
        address _init,
        bytes memory _calldata
    ) external override restricted {
        LibModuleManager.manageCommands(_commandModifications, _init, _calldata);
    }

    /* Modifiers
     *********************************************************************************************************/
    modifier checkDeadline(uint256 deadline) {
        if (block.timestamp > deadline) revert TransactionDeadlinePassed();
        _;
    }

    /**
     * @inheritdoc IExecutor
     */
    function execute(bytes calldata _commands, bytes[] calldata _inputs, uint256 _deadline)
        external
        payable
        override
        checkDeadline(_deadline)
    {
        execute(_commands, _inputs, false);
    }

    /**
     * @inheritdoc IExecutor
     */
    function execute(bytes calldata _commands, bytes[] calldata _inputs, uint256 _deadline, bool returnOutput)
        external
        payable
        checkDeadline(_deadline)
        returns (bytes[] memory returnData)
    {
        return execute(_commands, _inputs, returnOutput);
    }

    /**
     * @inheritdoc IExecutor
     */
    function execute(bytes calldata _commands, bytes[] calldata _inputs) public payable override {
        execute(_commands, _inputs, false);
    }

    /**
     * @inheritdoc IExecutor
     */
    function execute(bytes calldata _commands, bytes[] calldata _inputs, bool returnOutput)
        public
        payable
        returns (bytes[] memory returnData)
    {
        // EXECUTION STORAGE
        LibExecutionModule.ExecutionStorage storage es = LibExecutionModule.executionStorage();

        // Relying on msg.sender is problematic as it changes during a flash loan.
        // Thus, it's necessary to track who initiated the original Router execution.
        bool topLevel;
        if (es.msgSender == address(0)) {
            es.msgSender = msg.sender;
            topLevel = true;
            es.msgValue = msg.value;
        } else if (msg.sender != address(this)) {
            revert UnauthorizedReentrantCall();
        }

        returnData = _execute(_commands, _inputs, returnOutput);

        if (topLevel) {
            // top-level reset
            es.msgSender = address(0);
            es.msgValue = 0;
        }

        return returnData;
    }

    /**
     * @dev Internal function to execute commands with their inputs
     * @param _commands The commands to execute
     * @param _inputs The inputs for each command
     * @param returnOutput Whether to return output data
     * @return returnData The output data if returnOutput is true
     */
    function _execute(bytes memory _commands, bytes[] memory _inputs, bool returnOutput)
        internal
        returns (bytes[] memory returnData)
    {
        uint256 numCommands = _commands.length;
        if (_inputs.length != numCommands) {
            revert LengthMismatch();
        }

        if (returnOutput) {
            returnData = new bytes[](numCommands);
        }

        // loop through all given commands, execute them and pass along outputs as defined
        for (uint256 commandIndex; commandIndex < numCommands;) {
            bytes1 command = _commands[commandIndex];
            bytes memory input = _inputs[commandIndex];

            LibModuleManager.ModulesManagerStorage storage ds = LibModuleManager.modulesManagerStorage();
            // get implementation & function from the command
            address implementationAddress = ds.implementationAndFunction[command].implementation;
            bytes4 functionSelector = ds.implementationAndFunction[command].functionSelector;
            if (implementationAddress == address(0)) {
                revert CommandNotFound(command);
            }

            // Prepare calldata with function selector and input data
            bytes memory callData = abi.encodePacked(functionSelector, input);
            bool success;
            bytes memory result;

            // Execute external function from implementation using delegatecall
            assembly {
                // Calculate calldata memory pointer and length
                let ptr := add(callData, 32)
                let len := mload(callData)

                // Execute delegatecall
                success := delegatecall(gas(), implementationAddress, ptr, len, 0, 0)

                // Handle return data
                let returnDataSize := returndatasize()

                // Allocate memory for the result
                result := mload(0x40) // Get free memory pointer
                mstore(0x40, add(result, add(returnDataSize, 32))) // Update free memory pointer
                mstore(result, returnDataSize) // Store length

                // Copy return data
                returndatacopy(add(result, 32), 0, returnDataSize)
            }

            if (!success) {
                // Forward the revert message
                assembly {
                    let returnDataSize := mload(result)
                    revert(add(result, 32), returnDataSize)
                }
            }

            if (returnOutput) {
                // Store the return data from this command
                returnData[commandIndex] = result;
            }

            unchecked {
                commandIndex++;
            }
        }

        return returnData;
    }
}

dependencies/@openzeppelin-contracts-5.4.0-rc.1/access/manager/AuthorityUtils.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (access/manager/AuthorityUtils.sol)

pragma solidity ^0.8.20;

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

library AuthorityUtils {
    /**
     * @dev Since `AccessManager` implements an extended IAuthority interface, invoking `canCall` with backwards compatibility
     * for the preexisting `IAuthority` interface requires special care to avoid reverting on insufficient return data.
     * This helper function takes care of invoking `canCall` in a backwards compatible way without reverting.
     */
    function canCallWithDelay(
        address authority,
        address caller,
        address target,
        bytes4 selector
    ) internal view returns (bool immediate, uint32 delay) {
        bytes memory data = abi.encodeCall(IAuthority.canCall, (caller, target, selector));

        assembly ("memory-safe") {
            mstore(0x00, 0x00)
            mstore(0x20, 0x00)

            if staticcall(gas(), authority, add(data, 0x20), mload(data), 0x00, 0x40) {
                immediate := mload(0x00)
                delay := mload(0x20)

                // If delay does not fit in a uint32, return 0 (no delay)
                // equivalent to: if gt(delay, 0xFFFFFFFF) { delay := 0 }
                delay := mul(delay, iszero(shr(32, delay)))
            }
        }
    }
}

dependencies/@openzeppelin-contracts-5.4.0-rc.1/access/manager/IAccessManaged.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0-rc.0) (access/manager/IAccessManaged.sol)

pragma solidity >=0.8.4;

interface IAccessManaged {
    /**
     * @dev Authority that manages this contract was updated.
     */
    event AuthorityUpdated(address authority);

    error AccessManagedUnauthorized(address caller);
    error AccessManagedRequiredDelay(address caller, uint32 delay);
    error AccessManagedInvalidAuthority(address authority);

    /**
     * @dev Returns the current authority.
     */
    function authority() external view returns (address);

    /**
     * @dev Transfers control to a new authority. The caller must be the current authority.
     */
    function setAuthority(address) external;

    /**
     * @dev Returns true only in the context of a delayed restricted call, at the moment that the scheduled operation is
     * being consumed. Prevents denial of service for delayed restricted calls in the case that the contract performs
     * attacker controlled calls.
     */
    function isConsumingScheduledOp() external view returns (bytes4);
}

dependencies/@openzeppelin-contracts-5.4.0-rc.1/access/manager/IAccessManager.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0-rc.0) (access/manager/IAccessManager.sol)

pragma solidity >=0.8.4;

interface IAccessManager {
    /**
     * @dev A delayed operation was scheduled.
     */
    event OperationScheduled(
        bytes32 indexed operationId,
        uint32 indexed nonce,
        uint48 schedule,
        address caller,
        address target,
        bytes data
    );

    /**
     * @dev A scheduled operation was executed.
     */
    event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce);

    /**
     * @dev A scheduled operation was canceled.
     */
    event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);

    /**
     * @dev Informational labelling for a roleId.
     */
    event RoleLabel(uint64 indexed roleId, string label);

    /**
     * @dev Emitted when `account` is granted `roleId`.
     *
     * NOTE: The meaning of the `since` argument depends on the `newMember` argument.
     * If the role is granted to a new member, the `since` argument indicates when the account becomes a member of the role,
     * otherwise it indicates the execution delay for this account and roleId is updated.
     */
    event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember);

    /**
     * @dev Emitted when `account` membership or `roleId` is revoked. Unlike granting, revoking is instantaneous.
     */
    event RoleRevoked(uint64 indexed roleId, address indexed account);

    /**
     * @dev Role acting as admin over a given `roleId` is updated.
     */
    event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);

    /**
     * @dev Role acting as guardian over a given `roleId` is updated.
     */
    event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian);

    /**
     * @dev Grant delay for a given `roleId` will be updated to `delay` when `since` is reached.
     */
    event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since);

    /**
     * @dev Target mode is updated (true = closed, false = open).
     */
    event TargetClosed(address indexed target, bool closed);

    /**
     * @dev Role required to invoke `selector` on `target` is updated to `roleId`.
     */
    event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId);

    /**
     * @dev Admin delay for a given `target` will be updated to `delay` when `since` is reached.
     */
    event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since);

    error AccessManagerAlreadyScheduled(bytes32 operationId);
    error AccessManagerNotScheduled(bytes32 operationId);
    error AccessManagerNotReady(bytes32 operationId);
    error AccessManagerExpired(bytes32 operationId);
    error AccessManagerLockedRole(uint64 roleId);
    error AccessManagerBadConfirmation();
    error AccessManagerUnauthorizedAccount(address msgsender, uint64 roleId);
    error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector);
    error AccessManagerUnauthorizedConsume(address target);
    error AccessManagerUnauthorizedCancel(address msgsender, address caller, address target, bytes4 selector);
    error AccessManagerInvalidInitialAdmin(address initialAdmin);

    /**
     * @dev Check if an address (`caller`) is authorised to call a given function on a given contract directly (with
     * no restriction). Additionally, it returns the delay needed to perform the call indirectly through the {schedule}
     * & {execute} workflow.
     *
     * This function is usually called by the targeted contract to control immediate execution of restricted functions.
     * Therefore we only return true if the call can be performed without any delay. If the call is subject to a
     * previously set delay (not zero), then the function should return false and the caller should schedule the operation
     * for future execution.
     *
     * If `immediate` is true, the delay can be disregarded and the operation can be immediately executed, otherwise
     * the operation can be executed if and only if delay is greater than 0.
     *
     * NOTE: The IAuthority interface does not include the `uint32` delay. This is an extension of that interface that
     * is backward compatible. Some contracts may thus ignore the second return argument. In that case they will fail
     * to identify the indirect workflow, and will consider calls that require a delay to be forbidden.
     *
     * NOTE: This function does not report the permissions of the admin functions in the manager itself. These are defined by the
     * {AccessManager} documentation.
     */
    function canCall(
        address caller,
        address target,
        bytes4 selector
    ) external view returns (bool allowed, uint32 delay);

    /**
     * @dev Expiration delay for scheduled proposals. Defaults to 1 week.
     *
     * IMPORTANT: Avoid overriding the expiration with 0. Otherwise every contract proposal will be expired immediately,
     * disabling any scheduling usage.
     */
    function expiration() external view returns (uint32);

    /**
     * @dev Minimum setback for all delay updates, with the exception of execution delays. It
     * can be increased without setback (and reset via {revokeRole} in the case event of an
     * accidental increase). Defaults to 5 days.
     */
    function minSetback() external view returns (uint32);

    /**
     * @dev Get whether the contract is closed disabling any access. Otherwise role permissions are applied.
     *
     * NOTE: When the manager itself is closed, admin functions are still accessible to avoid locking the contract.
     */
    function isTargetClosed(address target) external view returns (bool);

    /**
     * @dev Get the role required to call a function.
     */
    function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64);

    /**
     * @dev Get the admin delay for a target contract. Changes to contract configuration are subject to this delay.
     */
    function getTargetAdminDelay(address target) external view returns (uint32);

    /**
     * @dev Get the id of the role that acts as an admin for the given role.
     *
     * The admin permission is required to grant the role, revoke the role and update the execution delay to execute
     * an operation that is restricted to this role.
     */
    function getRoleAdmin(uint64 roleId) external view returns (uint64);

    /**
     * @dev Get the role that acts as a guardian for a given role.
     *
     * The guardian permission allows canceling operations that have been scheduled under the role.
     */
    function getRoleGuardian(uint64 roleId) external view returns (uint64);

    /**
     * @dev Get the role current grant delay.
     *
     * Its value may change at any point without an event emitted following a call to {setGrantDelay}.
     * Changes to this value, including effect timepoint are notified in advance by the {RoleGrantDelayChanged} event.
     */
    function getRoleGrantDelay(uint64 roleId) external view returns (uint32);

    /**
     * @dev Get the access details for a given account for a given role. These details include the timepoint at which
     * membership becomes active, and the delay applied to all operation by this user that requires this permission
     * level.
     *
     * Returns:
     * [0] Timestamp at which the account membership becomes valid. 0 means role is not granted.
     * [1] Current execution delay for the account.
     * [2] Pending execution delay for the account.
     * [3] Timestamp at which the pending execution delay will become active. 0 means no delay update is scheduled.
     */
    function getAccess(
        uint64 roleId,
        address account
    ) external view returns (uint48 since, uint32 currentDelay, uint32 pendingDelay, uint48 effect);

    /**
     * @dev Check if a given account currently has the permission level corresponding to a given role. Note that this
     * permission might be associated with an execution delay. {getAccess} can provide more details.
     */
    function hasRole(uint64 roleId, address account) external view returns (bool isMember, uint32 executionDelay);

    /**
     * @dev Give a label to a role, for improved role discoverability by UIs.
     *
     * Requirements:
     *
     * - the caller must be a global admin
     *
     * Emits a {RoleLabel} event.
     */
    function labelRole(uint64 roleId, string calldata label) external;

    /**
     * @dev Add `account` to `roleId`, or change its execution delay.
     *
     * This gives the account the authorization to call any function that is restricted to this role. An optional
     * execution delay (in seconds) can be set. If that delay is non 0, the user is required to schedule any operation
     * that is restricted to members of this role. The user will only be able to execute the operation after the delay has
     * passed, before it has expired. During this period, admin and guardians can cancel the operation (see {cancel}).
     *
     * If the account has already been granted this role, the execution delay will be updated. This update is not
     * immediate and follows the delay rules. For example, if a user currently has a delay of 3 hours, and this is
     * called to reduce that delay to 1 hour, the new delay will take some time to take effect, enforcing that any
     * operation executed in the 3 hours that follows this update was indeed scheduled before this update.
     *
     * Requirements:
     *
     * - the caller must be an admin for the role (see {getRoleAdmin})
     * - granted role must not be the `PUBLIC_ROLE`
     *
     * Emits a {RoleGranted} event.
     */
    function grantRole(uint64 roleId, address account, uint32 executionDelay) external;

    /**
     * @dev Remove an account from a role, with immediate effect. If the account does not have the role, this call has
     * no effect.
     *
     * Requirements:
     *
     * - the caller must be an admin for the role (see {getRoleAdmin})
     * - revoked role must not be the `PUBLIC_ROLE`
     *
     * Emits a {RoleRevoked} event if the account had the role.
     */
    function revokeRole(uint64 roleId, address account) external;

    /**
     * @dev Renounce role permissions for the calling account with immediate effect. If the sender is not in
     * the role this call has no effect.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * Emits a {RoleRevoked} event if the account had the role.
     */
    function renounceRole(uint64 roleId, address callerConfirmation) external;

    /**
     * @dev Change admin role for a given role.
     *
     * Requirements:
     *
     * - the caller must be a global admin
     *
     * Emits a {RoleAdminChanged} event
     */
    function setRoleAdmin(uint64 roleId, uint64 admin) external;

    /**
     * @dev Change guardian role for a given role.
     *
     * Requirements:
     *
     * - the caller must be a global admin
     *
     * Emits a {RoleGuardianChanged} event
     */
    function setRoleGuardian(uint64 roleId, uint64 guardian) external;

    /**
     * @dev Update the delay for granting a `roleId`.
     *
     * Requirements:
     *
     * - the caller must be a global admin
     *
     * Emits a {RoleGrantDelayChanged} event.
     */
    function setGrantDelay(uint64 roleId, uint32 newDelay) external;

    /**
     * @dev Set the role required to call functions identified by the `selectors` in the `target` contract.
     *
     * Requirements:
     *
     * - the caller must be a global admin
     *
     * Emits a {TargetFunctionRoleUpdated} event per selector.
     */
    function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external;

    /**
     * @dev Set the delay for changing the configuration of a given target contract.
     *
     * Requirements:
     *
     * - the caller must be a global admin
     *
     * Emits a {TargetAdminDelayUpdated} event.
     */
    function setTargetAdminDelay(address target, uint32 newDelay) external;

    /**
     * @dev Set the closed flag for a contract.
     *
     * Closing the manager itself won't disable access to admin methods to avoid locking the contract.
     *
     * Requirements:
     *
     * - the caller must be a global admin
     *
     * Emits a {TargetClosed} event.
     */
    function setTargetClosed(address target, bool closed) external;

    /**
     * @dev Return the timepoint at which a scheduled operation will be ready for execution. This returns 0 if the
     * operation is not yet scheduled, has expired, was executed, or was canceled.
     */
    function getSchedule(bytes32 id) external view returns (uint48);

    /**
     * @dev Return the nonce for the latest scheduled operation with a given id. Returns 0 if the operation has never
     * been scheduled.
     */
    function getNonce(bytes32 id) external view returns (uint32);

    /**
     * @dev Schedule a delayed operation for future execution, and return the operation identifier. It is possible to
     * choose the timestamp at which the operation becomes executable as long as it satisfies the execution delays
     * required for the caller. The special value zero will automatically set the earliest possible time.
     *
     * Returns the `operationId` that was scheduled. Since this value is a hash of the parameters, it can reoccur when
     * the same parameters are used; if this is relevant, the returned `nonce` can be used to uniquely identify this
     * scheduled operation from other occurrences of the same `operationId` in invocations of {execute} and {cancel}.
     *
     * Emits a {OperationScheduled} event.
     *
     * NOTE: It is not possible to concurrently schedule more than one operation with the same `target` and `data`. If
     * this is necessary, a random byte can be appended to `data` to act as a salt that will be ignored by the target
     * contract if it is using standard Solidity ABI encoding.
     */
    function schedule(
        address target,
        bytes calldata data,
        uint48 when
    ) external returns (bytes32 operationId, uint32 nonce);

    /**
     * @dev Execute a function that is delay restricted, provided it was properly scheduled beforehand, or the
     * execution delay is 0.
     *
     * Returns the nonce that identifies the previously scheduled operation that is executed, or 0 if the
     * operation wasn't previously scheduled (if the caller doesn't have an execution delay).
     *
     * Emits an {OperationExecuted} event only if the call was scheduled and delayed.
     */
    function execute(address target, bytes calldata data) external payable returns (uint32);

    /**
     * @dev Cancel a scheduled (delayed) operation. Returns the nonce that identifies the previously scheduled
     * operation that is cancelled.
     *
     * Requirements:
     *
     * - the caller must be the proposer, a guardian of the targeted function, or a global admin
     *
     * Emits a {OperationCanceled} event.
     */
    function cancel(address caller, address target, bytes calldata data) external returns (uint32);

    /**
     * @dev Consume a scheduled operation targeting the caller. If such an operation exists, mark it as consumed
     * (emit an {OperationExecuted} event and clean the state). Otherwise, throw an error.
     *
     * This is useful for contract that want to enforce that calls targeting them were scheduled on the manager,
     * with all the verifications that it implies.
     *
     * Emit a {OperationExecuted} event.
     */
    function consumeScheduledOp(address caller, bytes calldata data) external;

    /**
     * @dev Hashing function for delayed operations.
     */
    function hashOperation(address caller, address target, bytes calldata data) external view returns (bytes32);

    /**
     * @dev Changes the authority of a target managed by this manager instance.
     *
     * Requirements:
     *
     * - the caller must be a global admin
     */
    function updateAuthority(address target, address newAuthority) external;
}

dependencies/@openzeppelin-contracts-5.4.0-rc.1/access/manager/IAuthority.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0-rc.0) (access/manager/IAuthority.sol)

pragma solidity >=0.4.16;

/**
 * @dev Standard interface for permissioning originally defined in Dappsys.
 */
interface IAuthority {
    /**
     * @dev Returns true if the caller can invoke on a target the function identified by a function selector.
     */
    function canCall(address caller, address target, bytes4 selector) external view returns (bool allowed);
}

dependencies/@openzeppelin-contracts-upgradeable-5.4.0-rc.1/access/manager/AccessManagedUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0-rc.0) (access/manager/AccessManaged.sol)

pragma solidity ^0.8.20;

import {AuthorityUtils} from "@openzeppelin/contracts/access/manager/AuthorityUtils.sol";
import {IAccessManager} from "@openzeppelin/contracts/access/manager/IAccessManager.sol";
import {IAccessManaged} from "@openzeppelin/contracts/access/manager/IAccessManaged.sol";
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";

/**
 * @dev This contract module makes available a {restricted} modifier. Functions decorated with this modifier will be
 * permissioned according to an "authority": a contract like {AccessManager} that follows the {IAuthority} interface,
 * implementing a policy that allows certain callers to access certain functions.
 *
 * IMPORTANT: The `restricted` modifier should never be used on `internal` functions, judiciously used in `public`
 * functions, and ideally only used in `external` functions. See {restricted}.
 */
abstract contract AccessManagedUpgradeable is Initializable, ContextUpgradeable, IAccessManaged {
    /// @custom:storage-location erc7201:openzeppelin.storage.AccessManaged
    struct AccessManagedStorage {
        address _authority;

        bool _consumingSchedule;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessManaged")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant AccessManagedStorageLocation = 0xf3177357ab46d8af007ab3fdb9af81da189e1068fefdc0073dca88a2cab40a00;

    function _getAccessManagedStorage() private pure returns (AccessManagedStorage storage $) {
        assembly {
            $.slot := AccessManagedStorageLocation
        }
    }

    /**
     * @dev Initializes the contract connected to an initial authority.
     */
    function __AccessManaged_init(address initialAuthority) internal onlyInitializing {
        __AccessManaged_init_unchained(initialAuthority);
    }

    function __AccessManaged_init_unchained(address initialAuthority) internal onlyInitializing {
        _setAuthority(initialAuthority);
    }

    /**
     * @dev Restricts access to a function as defined by the connected Authority for this contract and the
     * caller and selector of the function that entered the contract.
     *
     * [IMPORTANT]
     * ====
     * In general, this modifier should only be used on `external` functions. It is okay to use it on `public`
     * functions that are used as external entry points and are not called internally. Unless you know what you're
     * doing, it should never be used on `internal` functions. Failure to follow these rules can have critical security
     * implications! This is because the permissions are determined by the function that entered the contract, i.e. the
     * function at the bottom of the call stack, and not the function where the modifier is visible in the source code.
     * ====
     *
     * [WARNING]
     * ====
     * Avoid adding this modifier to the https://docs.soliditylang.org/en/v0.8.20/contracts.html#receive-ether-function[`receive()`]
     * function or the https://docs.soliditylang.org/en/v0.8.20/contracts.html#fallback-function[`fallback()`]. These
     * functions are the only execution paths where a function selector cannot be unambiguously determined from the calldata
     * since the selector defaults to `0x00000000` in the `receive()` function and similarly in the `fallback()` function
     * if no calldata is provided. (See {_checkCanCall}).
     *
     * The `receive()` function will always panic whereas the `fallback()` may panic depending on the calldata length.
     * ====
     */
    modifier restricted() {
        _checkCanCall(_msgSender(), _msgData());
        _;
    }

    /// @inheritdoc IAccessManaged
    function authority() public view virtual returns (address) {
        AccessManagedStorage storage $ = _getAccessManagedStorage();
        return $._authority;
    }

    /// @inheritdoc IAccessManaged
    function setAuthority(address newAuthority) public virtual {
        address caller = _msgSender();
        if (caller != authority()) {
            revert AccessManagedUnauthorized(caller);
        }
        if (newAuthority.code.length == 0) {
            revert AccessManagedInvalidAuthority(newAuthority);
        }
        _setAuthority(newAuthority);
    }

    /// @inheritdoc IAccessManaged
    function isConsumingScheduledOp() public view returns (bytes4) {
        AccessManagedStorage storage $ = _getAccessManagedStorage();
        return $._consumingSchedule ? this.isConsumingScheduledOp.selector : bytes4(0);
    }

    /**
     * @dev Transfers control to a new authority. Internal function with no access restriction. Allows bypassing the
     * permissions set by the current authority.
     */
    function _setAuthority(address newAuthority) internal virtual {
        AccessManagedStorage storage $ = _getAccessManagedStorage();
        $._authority = newAuthority;
        emit AuthorityUpdated(newAuthority);
    }

    /**
     * @dev Reverts if the caller is not allowed to call the function identified by a selector. Panics if the calldata
     * is less than 4 bytes long.
     */
    function _checkCanCall(address caller, bytes calldata data) internal virtual {
        AccessManagedStorage storage $ = _getAccessManagedStorage();
        (bool immediate, uint32 delay) = AuthorityUtils.canCallWithDelay(
            authority(),
            caller,
            address(this),
            bytes4(data[0:4])
        );
        if (!immediate) {
            if (delay > 0) {
                $._consumingSchedule = true;
                IAccessManager(authority()).consumeScheduledOp(caller, data);
                $._consumingSchedule = false;
            } else {
                revert AccessManagedUnauthorized(caller);
            }
        }
    }
}

dependencies/@openzeppelin-contracts-upgradeable-5.4.0-rc.1/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.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 reinitialization) 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 Pointer to storage slot. Allows integrators to override it with a custom storage location.
     *
     * NOTE: Consider following the ERC-7201 formula to derive storage locations.
     */
    function _initializableStorageSlot() internal pure virtual returns (bytes32) {
        return INITIALIZABLE_STORAGE;
    }

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

dependencies/@openzeppelin-contracts-upgradeable-5.4.0-rc.1/utils/ContextUpgradeable.sol

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

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

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

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

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

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

dependencies/diamond-router-V1/src/interfaces/ICommand.sol

pragma solidity ^0.8.22;

interface ICommand {
        enum ImplementationAction {
        Add,
        Replace,
        Remove
    }
    // Add=0, Replace=1, Remove=2

    struct CommandModification {
        address implementation; // implementation address
        ImplementationAction action; // action to realize
        bytes commands; // command IDs to associate with function selectors
        bytes4[] functionSelectors; // one command is associated to one function selector
    }

    event CommandModifications(
        CommandModification[] _commandModifications, address _init, bytes _calldata
    );

}

dependencies/diamond-router-V1/src/interfaces/ICommandManager.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ICommand} from "./ICommand.sol";
interface ICommandManager {

    /// @notice Add/replace/remove any number of functions and optionally execute
    ///         a function with delegatecall
    /// @param _commandModifications Array of implementation addresses, actions, commands,
    ///                                     and function selectors
    /// @param _init The address of the contract or facet to execute _calldata
    /// @param _calldata A function call executed with delegatecall on _init
    function manageCommands(
        ICommand.CommandModification[] memory _commandModifications,
        address _init,
        bytes memory _calldata
    ) external;
}

dependencies/diamond-router-V1/src/interfaces/IExecutor.sol

// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.20;

// https://github.com/Uniswap/universal-router/blob/main/contracts/interfaces/IUniversalRouter.sol

interface IExecutor {
    /// @notice Thrown when executing commands with an expired deadline
    error TransactionDeadlinePassed();

    /// @notice Thrown when attempting to execute commands and an incorrect number of inputs are provided
    error LengthMismatch();

    /// @notice Thrown when onFlashloan() is called directly, rather than through a command execution
    error DirectOnFlashloanCall();

    /// @notice Thrown when onFlashloan() is called by an address other than flashloan lender
    error UnauthorizedOnFlashloanCaller();

    /// @notice Thrown when an address other than msgSender and Router reenters execute()
    error UnauthorizedReentrantCall();

    /// @notice Thrown when the command isn't associated to a valid function
    error CommandNotFound(bytes1 command);

    /**
     * @dev Executes encoded commands along with provided inputs
     * Reverts if deadline has expired
     * @param _commands A set of concatenated commands, each 1 byte in length
     * @param _inputs An array of byte strings containing ABI-encoded inputs for each command
     * @param _deadline The deadline by which the transaction must be executed
     */
    function execute(bytes calldata _commands, bytes[] calldata _inputs, uint256 _deadline) external payable;

    /**
     * @dev Executes encoded commands along with provided inputs
     * @param _commands A set of concatenated commands, each 1 byte in length
     * @param _inputs An array of byte strings containing ABI-encoded inputs for each command
     */
    function execute(bytes calldata _commands, bytes[] calldata _inputs) external payable;

    /**
     * @dev Executes encoded commands along with provided inputs and returns the output
     * Reverts if deadline has expired
     * @param _commands A set of concatenated commands, each 1 byte in length
     * @param _inputs An array of byte strings containing ABI-encoded inputs for each command
     * @param _deadline The deadline by which the transaction must be executed
     * @param returnOutput Whether to return the output data
     * @return returnData The output data from the executed commands
     */
    function execute(bytes calldata _commands, bytes[] calldata _inputs, uint256 _deadline, bool returnOutput)
        external
        payable
        returns (bytes[] memory returnData);

    /**
     * @dev Executes encoded commands along with provided inputs and returns the output
     * @param _commands A set of concatenated commands, each 1 byte in length
     * @param _inputs An array of byte strings containing ABI-encoded inputs for each command
     * @param returnOutput Whether to return the output data
     * @return returnData The output data from the executed commands
     */
    function execute(bytes calldata _commands, bytes[] calldata _inputs, bool returnOutput)
        external
        payable
        returns (bytes[] memory returnData);
}

dependencies/diamond-router-V1/src/modules/libraries/LibExecutionModule.sol

pragma solidity ^0.8.20;

library LibExecutionModule {
    // EIP-7201: keccak256(abi.encode(uint256(keccak256("native.execution.storage")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 constant EXECUTION_STORAGE_POSITION = keccak256(abi.encode(uint256(keccak256("native.execution.storage")) - 1)) & ~bytes32(uint256(0xff));

    struct ExecutionStorage {
        address msgSender;
        uint256 msgValue;
    }

    function executionStorage() internal pure returns (ExecutionStorage storage es) {
        bytes32 position = EXECUTION_STORAGE_POSITION;
        assembly {
            es.slot := position
        }
    }

    function getMsgSender() internal view returns(address) {
        return executionStorage().msgSender;
    }

    function getMsgValue() internal view returns(uint256) {
        return executionStorage().msgValue;
    }
}

dependencies/diamond-router-V1/src/modules/libraries/LibModuleManager.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ICommandManager, ICommand} from "src/interfaces/ICommandManager.sol";

// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.
// The loupe functions are required by the EIP2535 Diamonds standard

error EmptyCommandList();
error MissmatchLength();
error NoSelectorsProvidedForFacetForCut(address _facetAddress);
error CannotAddSelectorsToZeroAddress(bytes4[] _selectors);
error NoBytecodeAtAddress(address _contractAddress);
error CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector);
error CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors);
error CannotReplaceImmutableFunction(bytes4 _selector);
error CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(bytes4 _selector);
error CannotReplaceFunctionThatDoesNotExists(bytes4 _selector);
error RemoveFacetAddressMustBeZeroAddress(address _facetAddress);
error CannotRemoveFunctionThatDoesNotExist(bytes4 _selector);
error CannotRemoveImmutableFunction(bytes4 _selector);
error IncorrectManagementAction(uint8 _action);
error InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);
error CommandAlreadyRegistered(bytes1 commandId);

library LibModuleManager {
    // EIP-7201: keccak256(abi.encode(uint256(keccak256("native.modules.storage")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 constant MODULES_STORAGE_POSITION = keccak256(abi.encode(uint256(keccak256("native.modules.storage")) - 1)) & ~bytes32(uint256(0xff));

    struct ImplementationAndFunction {
        address implementation;
        bytes4 functionSelector;
    }

    struct ModulesManagerStorage {
        // function selector => facet address and selector position in selectors array
        mapping(bytes1 => ImplementationAndFunction) implementationAndFunction;
        bytes1[] commands;
    }

    // Events
    event CommandModifications(
        ICommand.CommandModification[] _commandModifications, address _init, bytes _calldata
    );

    function modulesManagerStorage() internal pure returns (ModulesManagerStorage storage mms) {
        bytes32 position = MODULES_STORAGE_POSITION;
        assembly {
            mms.slot := position
        }
    }

    function manageCommands(
        ICommand.CommandModification[] memory _commandModifications,
        address _init,
        bytes memory _calldata
    ) internal {
        for (
            uint256 implementationIndex;
            implementationIndex < _commandModifications.length;
            implementationIndex++
        ) {
            bytes memory commands = _commandModifications[implementationIndex].commands;
            bytes4[] memory selectors = _commandModifications[implementationIndex].functionSelectors;
            address implementation = _commandModifications[implementationIndex].implementation;
            if (commands.length != selectors.length) {
                revert MissmatchLength();
            }
            if (commands.length == 0) {
                revert EmptyCommandList();
            }
            ICommand.ImplementationAction action = _commandModifications[implementationIndex].action;
            if (action == ICommand.ImplementationAction.Add) {
                addFunctions(implementation, commands, selectors);
            } else if (action == ICommand.ImplementationAction.Replace) {
                replaceFunctions(implementation, commands, selectors);
            } else if (action == ICommand.ImplementationAction.Remove) {
                removeFunctions(implementation, commands, selectors);
            } else {
                revert IncorrectManagementAction(uint8(action));
            }
        }
        emit CommandModifications(_commandModifications, _init, _calldata);
        initializeImplementation(_init, _calldata);
    }

    function addFunctions(address _implementationAddress, bytes memory _commands, bytes4[] memory _functionSelectors)
        internal
    {
        if (_implementationAddress == address(0)) {
            revert CannotAddSelectorsToZeroAddress(_functionSelectors);
        }
        ModulesManagerStorage storage mms = modulesManagerStorage();
        enforceHasContractCode(_implementationAddress);
        for (uint256 commandIndex; commandIndex < _commands.length; commandIndex++) {
            bytes1 command = _commands[commandIndex];
            bytes4 selector = _functionSelectors[commandIndex];
            // Check if command is already registered by searching for implementation
            address oldImplementationAddress = mms.implementationAndFunction[command].implementation;
            if (oldImplementationAddress != address(0)) {
                revert CommandAlreadyRegistered(command);
            }

            // Add to commands array for enumeration
            mms.commands.push(command);
            mms.implementationAndFunction[command] = ImplementationAndFunction(_implementationAddress, selector);
        }
    }

    //this function replace the current address & selector associated to a command
    function replaceFunctions(
        address _implementationAddress,
        bytes memory _commands,
        bytes4[] memory _functionSelectors
    ) internal {
        ModulesManagerStorage storage mms = modulesManagerStorage();
        if (_implementationAddress == address(0)) {
            revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors);
        }
        enforceHasContractCode(_implementationAddress);
        for (uint256 commandIndex; commandIndex < _commands.length; commandIndex++) {
            bytes1 command = _commands[commandIndex];
            bytes4 selector = _functionSelectors[commandIndex];
            address oldImplementationAddress = mms.implementationAndFunction[command].implementation;
            if (oldImplementationAddress == _implementationAddress) {
                revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet(selector);
            }
            if (oldImplementationAddress == address(0)) {
                revert CannotReplaceFunctionThatDoesNotExists(selector);
            }
            // replace old facet address
            mms.implementationAndFunction[command].implementation = _implementationAddress;
            mms.implementationAndFunction[command].functionSelector = selector;
        }
    }

    /// notice: this function keeps the storage of the implementation of the removed function
    function removeFunctions(address _facetAddress, bytes memory commands, bytes4[] memory _functionSelectors)
        internal
    {
        ModulesManagerStorage storage mms = modulesManagerStorage();
        if (_facetAddress != address(0)) {
            revert RemoveFacetAddressMustBeZeroAddress(_facetAddress);
        }
        for (uint256 commandIndex; commandIndex < commands.length; commandIndex++) {
            bytes1 command = commands[commandIndex];
            bytes4 selector = _functionSelectors[commandIndex];

            ImplementationAndFunction memory implementationAndFunction = mms.implementationAndFunction[command];
            if (implementationAndFunction.implementation == address(0)) {
                revert CannotRemoveFunctionThatDoesNotExist(selector);
            }

            // can't remove immutable functions -- functions defined directly in the diamond
            if (implementationAndFunction.implementation == address(this)) {
                revert CannotRemoveImmutableFunction(selector);
            }

            // Remove command from commands array
            for (uint256 i = 0; i < mms.commands.length; i++) {
                if (mms.commands[i] == command) {
                    // Replace with the last element and pop
                    mms.commands[i] = mms.commands[mms.commands.length - 1];
                    mms.commands.pop();
                    break;
                }
            }

            // delete last selector
            delete mms.implementationAndFunction[command];
        }
    }

    function initializeImplementation(address _init, bytes memory _calldata) internal {
        if (_init == address(0)) {
            return;
        }
        enforceHasContractCode(_init);
        (bool success, bytes memory error) = _init.delegatecall(_calldata);
        if (!success) {
            if (error.length > 0) {
                // bubble up error
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(error)
                    revert(add(32, error), returndata_size)
                }
            } else {
                revert InitializationFunctionReverted(_init, _calldata);
            }
        }
    }

    function enforceHasContractCode(address _contract) internal view {
        uint256 contractSize;
        assembly {
            contractSize := extcodesize(_contract)
        }
        if (contractSize == 0) {
            revert NoBytecodeAtAddress(_contract);
        }
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "prague",
  "remappings": [
    "config/=dependencies/spectra-contracts-configs-main/script/",
    "core-v2/=dependencies/core-v2-staging/",
    "dependencies/@openzeppelin-contracts-upgradeable-5.4.0-rc.1/:@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.4.0-rc.1/",
    "dependencies/core-v2-staging:script/=dependencies/core-v2-staging/script/",
    "dependencies/core-v2-staging:src/=dependencies/core-v2-staging/src/",
    "dependencies/diamond-router-V1/:src/=dependencies/diamond-router-V1/src/",
    "dependencies/limit-orders-beta:script/=dependencies/limit-orders-beta/script/",
    "dependencies/limit-orders-beta:src/=dependencies/limit-orders-beta/src/",
    "dependencies/spectra-bridge-stellar-main/:@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.4.0-rc.1/",
    "dependencies/spectra-bridge-stellar-main/:@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.4.0-rc.1/",
    "dependencies/spectra-bridge-stellar-main:src/=dependencies/spectra-bridge-stellar-main/contracts/evm/src/",
    "diamond-router/=dependencies/diamond-router-V1/",
    "forge-std/=dependencies/forge-std-1.9.7/src/",
    "limit-orders/=dependencies/limit-orders-beta/",
    "openzeppelin-contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.4.0-rc.1/",
    "openzeppelin-contracts/=dependencies/@openzeppelin-contracts-5.4.0-rc.1/",
    "roles/=dependencies/spectra-contracts-configs-main/access/",
    "spectra-bridge-stellar/=dependencies/spectra-bridge-stellar-main/contracts/evm/",
    "@openzeppelin-contracts-5.4.0-rc.1/=dependencies/@openzeppelin-contracts-5.4.0-rc.1/",
    "@openzeppelin-contracts-upgradeable-5.4.0-rc.1/=dependencies/@openzeppelin-contracts-upgradeable-5.4.0-rc.1/",
    "core-v2-staging/=dependencies/core-v2-staging/src/",
    "diamond-router-V1/=dependencies/diamond-router-V1/",
    "ds-test/=dependencies/diamond-router-V1/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=dependencies/diamond-router-V1/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "forge-std-1.9.7/=dependencies/forge-std-1.9.7/src/",
    "halmos-cheatcodes/=dependencies/diamond-router-V1/lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
    "limit-orders-beta/=dependencies/limit-orders-beta/src/",
    "openzeppelin-erc20-basic/=dependencies/core-v2-staging/dependencies/diamond-router-V1/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/token/ERC20/",
    "openzeppelin-math/=dependencies/core-v2-staging/dependencies/diamond-router-V1/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/utils/math/",
    "solidity-stringutils/=dependencies/core-v2-staging/dependencies/diamond-router-V1/lib/solidity-stringutils/",
    "spectra-bridge-stellar-main/=dependencies/spectra-bridge-stellar-main/contracts/evm/src/",
    "spectra-contracts-configs-main/=dependencies/spectra-contracts-configs-main/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.