Withdrawer

Description:

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

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

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

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

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;


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

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

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

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

    function __AccessControl_init() internal onlyInitializing {
    }

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

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

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

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

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

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

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

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

        _revokeRole(role, callerConfirmation);
    }

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

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

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        AccessControlStorage storage $ = _getAccessControlStorage();
        if (hasRole(role, account)) {
            $._roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (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;
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165Upgradeable is Initializable, IERC165 {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
"
    },
    "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Pausable
    struct PausableStorage {
        bool _paused;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;

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

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

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

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

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

    function __Pausable_init_unchained() internal onlyInitializing {
        PausableStorage storage $ = _getPausableStorage();
        $._paused = false;
    }

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        PausableStorage storage $ = _getPausableStorage();
        $._paused = false;
        emit Unpaused(_msgSender());
    }
}
"
    },
    "@openzeppelin/contracts/access/IAccessControl.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

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

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

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}
"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}
"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}
"
    },
    "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

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

import {
    AccessControlUpgradeable
} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {OwnableReadonlyDS} from "./OwnableReadonlyDS.sol";

abstract contract AccessControlDS is AccessControlUpgradeable, OwnableReadonlyDS {
    function hasRole(bytes32 _role, address _account) public view virtual override returns (bool) {
        return (isOwnerRole(_role) && _owner() == _account) || super.hasRole(_role, _account);
    }

    function isOwnerRole(bytes32 _role) private pure returns (bool) {
        return _role == DEFAULT_ADMIN_ROLE;
    }
}
"
    },
    "contracts/base/auth/OwnableReadonly.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

import {UnauthorizedAccount} from "contracts/interfaces/base/CommonErrors.sol";
import {Address} from "contracts/libraries/Address.sol";

/**
 * @dev We intentionally do not expose "owner()" publicly
 * due to possible conflicts with "OwnershipFacet"
 * https://github.com/mudgen/diamond-3-hardhat/blob/main/contracts/facets/OwnershipFacet.sol
 */
abstract contract OwnableReadonly {
    using Address for bytes32;

    modifier onlyOwner() {
        enforceIsContractOwner();
        _;
    }

    function _owner() internal view returns (address) {
        return _ownerSlot().get();
    }

    function _ownerSlot() internal pure virtual returns (bytes32);

    function enforceIsContractOwner() private view {
        if (msg.sender != _owner()) revert UnauthorizedAccount(msg.sender);
    }
}
"
    },
    "contracts/base/auth/OwnableReadonlyDS.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

import {DiamondLibrary} from "contracts/libraries/DiamondLibrary.sol";
import {OwnableReadonly} from "./OwnableReadonly.sol";

/**
 * @notice Use DiamondStorage's owner slot for OwnableReadonly
 */
abstract contract OwnableReadonlyDS is OwnableReadonly {
    function _ownerSlot() internal pure override returns (bytes32 slot_) {
        DiamondLibrary.DiamondStorage storage ds = DiamondLibrary.diamondStorage();
        assembly {
            // DiamondLib will not change so it's safe to hardcode owner offset here
            let ownerOffsetInDiamondStorage := 4
            slot_ := add(ds.slot, ownerOffsetInDiamondStorage)
        }
    }
}
"
    },
    "contracts/base/pauser/base/PausableBase.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.22;

import {
    PausableUpgradeable
} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import {IPausable} from "contracts/interfaces/base/pauser/IPausable.sol";

abstract contract PausableBase is IPausable, PausableUpgradeable {
    bytes32 public constant override PAUSER_ROLE = keccak256("Pauser Role");

    modifier onlyPauserRole() {
        _checkRole(PAUSER_ROLE);
        _;
    }

    function pause() external override onlyPauserRole {
        _pause();
    }

    function unpause() external override onlyPauserRole {
        _unpause();
    }

    function paused() public view override(IPausable, PausableUpgradeable) returns (bool) {
        return PausableUpgradeable.paused();
    }

    /*
     * @dev Contracts inheriting from PausableBase should inherit OpenZeppelin's AccessControlUpgradeable
     *      override and implement _checkRole()
     */
    /* solhint-disable-next-line no-empty-blocks */
    function _checkRole(bytes32 role) internal view virtual {}
}
"
    },
    "contracts/base/pauser/PausableDS.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.22;

import {AccessControlDS, AccessControlUpgradeable} from "contracts/base/auth/AccessControlDS.sol";
import {PausableBase} from "contracts/base/pauser/base/PausableBase.sol";

contract PausableDS is PausableBase, AccessControlDS {
    function _checkRole(
        bytes32 role
    ) internal view override(AccessControlUpgradeable, PausableBase) {
        AccessControlUpgradeable._checkRole(role);
    }
}
"
    },
    "contracts/base/StateMachine.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

import {LibBit} from "solady/src/utils/LibBit.sol";

type State is uint256;

using {and as &, neq as !=, eq as ==, or as |, includes, isInitialized, isValid} for State global;

function and(State self, State value) pure returns (State) {
    return State.wrap(State.unwrap(self) & State.unwrap(value));
}

function neq(State self, State value) pure returns (bool) {
    return State.unwrap(self) != State.unwrap(value);
}

function eq(State self, State value) pure returns (bool) {
    return State.unwrap(self) == State.unwrap(value);
}

function or(State self, State value) pure returns (State) {
    return State.wrap(State.unwrap(self) | State.unwrap(value));
}

function includes(State bitmap, State state) pure returns (bool) {
    return State.unwrap(bitmap) & State.unwrap(state) != 0;
}

function isInitialized(State self) pure returns (bool answer_) {
    return State.unwrap(self) != 0;
}

function isValid(State self) pure returns (bool) {
    // most significant bit is reserved for the undefined state
    uint256 mask = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
    return LibBit.isPo2(State.unwrap(self) & mask);
}

abstract contract StateMachine {
    struct StateStorage {
        State currentState;
        mapping(bytes32 transitionId => function(bytes memory) external transition) transitions;
    }

    // Undefined state cannot be zero because it will break bitmap comparison math in `onlyState`
    /* solhint-disable-next-line immutable-vars-naming */
    State internal immutable STATE_UNDEFINED = _newStateFromIdUnchecked(STATE_UNDEFINED_ID);
    uint8 private constant STATE_UNDEFINED_ID = type(uint8).max;
    // keccak256("StateMachine storage slot V2");
    bytes32 private constant STORAGE_SLOT_STATE_MACHINE =
        0xde4001bbdfdfed078acd4ae5c1023679bf2e3e2982cfd37f7c839d62304fe30d;

    event StateChanged(State from, State to);

    error TransitionAlreadyExists(State from, State to);
    error TransitionDoesNotExist(State from, State to);

    error UnexpectedState(State expectedStatesBitmap, State currentState);
    // If transition function exists on current contract
    // then it must be called only from the current contract.
    error HostedTransitionMustBeCalledFromSelf();
    // A valid state must be in form of 2^n, where n ∈ {x | x ∈ uint8, x < STATE_UNDEFINED_ID}.
    error InvalidState(State);
    error IdIsReservedForUndefinedState(uint256);

    modifier onlyState(State _expectedStatesBitmap) {
        State state = _currentState(_stateStorage());
        if (!_expectedStatesBitmap.includes(state))
            revert UnexpectedState(_expectedStatesBitmap, state);
        _;
    }

    modifier transition() {
        if (msg.sender != address(this)) revert HostedTransitionMustBeCalledFromSelf();
        _;
    }

    function createTransition(
        State _from,
        State _to,
        function(bytes memory) external _transition
    ) internal {
        bytes32 id = _getTransitionId(_from, _to);
        if (_isTransitionExists(id)) revert TransitionAlreadyExists(_from, _to);

        _stateStorage().transitions[id] = _transition;
    }

    function changeState(State _newState) internal {
        changeState(_newState, "");
    }

    function changeState(State _newState, bytes memory _transitionArgs) internal {
        if (!_newState.isValid()) revert InvalidState(_newState);
        StateStorage storage $ = _stateStorage();
        State state = _currentState($);

        bytes32 id = _getTransitionId(state, _newState);
        if (!_isTransitionExists(id)) revert TransitionDoesNotExist(state, _newState);

        emit StateChanged(state, _newState);
        $.currentState = _newState;

        $.transitions[id](_transitionArgs);
    }

    function currentState() internal view returns (State currentState_) {
        return _currentState(_stateStorage());
    }

    function newStateFromId(uint8 _stateId) internal pure returns (State) {
        if (_stateId == STATE_UNDEFINED_ID) revert IdIsReservedForUndefinedState(_stateId);
        return _newStateFromIdUnchecked(_stateId);
    }

    function _currentState(StateStorage storage $) private view returns (State state) {
        state = $.currentState;
        // We substitute 0 with STATE_UNDEFINED here in order to avoid storage
        // initialization with default value to save gas
        if (!state.isInitialized()) state = STATE_UNDEFINED;
    }

    function _isTransitionExists(bytes32 _transitionId) private view returns (bool exists_) {
        mapping(bytes32 => function(bytes memory) external) storage map = _stateStorage()
            .transitions;
        assembly {
            // we won't use this memory location after keccak so it's safe to use 0x00 and 0x20
            mstore(0x00, _transitionId)
            mstore(0x20, map.slot)
            let position := keccak256(0x00, 64)
            // callback = map[_transition]
            let callback := sload(position)
            // exists_ = callback != null
            exists_ := iszero(iszero(callback))
        }
    }

    function _getTransitionId(State _from, State _to) private view returns (bytes32) {
        if (_from != STATE_UNDEFINED && !_from.isValid()) revert InvalidState(_from);
        if (!_to.isValid()) revert InvalidState(_to);
        return keccak256(abi.encodePacked(_from, _to));
    }

    function _newStateFromIdUnchecked(uint8 _stateId) private pure returns (State) {
        return State.wrap(1 << _stateId);
    }

    function _stateStorage() private pure returns (StateStorage storage $) {
        assembly {
            $.slot := STORAGE_SLOT_STATE_MACHINE
        }
    }
}
"
    },
    "contracts/interfaces/base/CommonErrors.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

/**
 * @notice An error indicating that the amount for the specified token is zero.
 * @param token The address of the token with a zero amount.
 */
error AmountMustNotBeZero(address token);

/**
 * @notice An error indicating that an address must not be zero.
 */
error AddressMustNotBeZero();

/**
 * @notice An error indicating that an array must not be empty.
 */
error ArrayMustNotBeEmpty();

/**
 * @notice An error indicating that an string must not be empty.
 */
error StringMustNotBeEmpty();

/**
 * @notice An error indicating storage is already up to date and doesn't need further processing.
 * @dev This error is thrown when attempting to update an entity(s) that is(are) already up to date.
 */
error AlreadyUpToDate();

/**
 * @notice An error indicating that an action is unauthorized for the specified account.
 * @param account The address of the unauthorized account.
 */
error UnauthorizedAccount(address account);

/**
 * @notice An error indicating that the min amount out must not be zero.
 */
error MinAmountOutMustNotBeZero();
"
    },
    "contracts/interfaces/base/IERC165Extended.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

/* solhint-disable no-unused-import */
import {
    IERC165
} from "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
/* solhint-enable no-unused-import */

/**
 * @notice An error indicating that an address does not support the expected interface
 * @param implementation The address that does not implement the required interface
 */
error UnsupportedInterface(address implementation);

/**
 * @dev Extended interface of the ERC165 standard to ensure compatibility
 * with Diamond facets as defined in EIP-2535.
 *
 * This interface extends the basic ERC165 mechanism to provide additional
 * flexibility for querying supported interfaces, which can then be
 * dynamically resolved by one of facets in a Diamond.
 */
interface IERC165Extended {
    /**
     * @notice Checks if the given interface ID is supported by the contract.
     * @param interfaceId The ID of the interface to query.
     * @return isSupported Boolean value indicating whether the interface is supported.
     */
    function supportsInterfaceExtended(bytes4 interfaceId) external pure returns (bool isSupported);
}
"
    },
    "contracts/interfaces/base/pauser/IPausable.sol": {
      "content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;

/**
 * @dev Interface for contracts that can be paused or unpaused.
 * This interface provides the methods to pause and unpause the contract
 * as well as check its paused status. It also includes the definition of
 * the `PAUSER_ROLE` that is required to perform the pause/unpause actions.
 */
interface IPausable {
    /**
     * @notice Pauses the contract.
     * @dev Can only be called by an address with the `PAUSER_ROLE`.
     *      This function will halt any operations that are paused in the contract.
     */
    function pause() external;

    /**
     * @notice Unpauses the contract.
     * @dev Can only be called by an address with the `PAUSER_ROLE`.
     *      This function will resume any operations that were paused in the contract.
     */
    function unpause() external;

    /**
     * @notice Returns whether the contract is paused.
     * @return bool True if the contract is paused, false otherwise.
     * @dev This function checks the contract's paused status, which is typically
     *      managed by an internal flag set by the `pause` and `unpause` functions.
     */
    function paused() external view returns (bool);

    /**
     * @notice Returns the role identifier for the `PAUSER_ROLE`.
     * @return bytes32 The role identifier for the `PAUSER_ROLE`.
     * @dev The `PAUSER_ROLE` is required for the caller to invoke the `pause` or `unpause` functions.
     */
    /* solhint-disable-next-line func-name-mixedcase */
    function PAUSER_ROLE() external view returns (bytes32);
}
"
    },
    "contracts/interfaces/common/IInitializable.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

interface IInitializable {
    function initialize() external;
}
"
    },
    "contracts/interfaces/compiler/adapters/IDecreasePositionEvaluator.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

import {Asset} from "contracts/libraries/AssetLibrary.sol";
import {Command} from "../Command.sol";
import {PositionDescriptor} from "./PositionDescriptor.sol";

interface IDecreasePositionEvaluator {
    /**
     * @notice Request structure for decreasing a position.
     * @dev `descriptor`: The [`PositionDescriptor`](/interfaces/compiler/adapters/PositionDescriptor.sol/struct.PositionDescriptor.html)
     *  struct.
     * @dev `liquidity`: Abstract amount that can be interpreted differently in different protocols (e.g., amount of LP tokens to burn).
     * @dev `minOutput`: [`Asset`](/interfaces/compliance/Asset.sol/struct.Asset.html) array with minimum amounts that must be retrieved from the position.
     */
    struct DecreasePositionRequest {
        PositionDescriptor descriptor;
        uint256 liquidity;
        Asset[] minOutput;
    }

    /**
     * @notice Evaluate a decrease position request.
     * @param _operator Address which initiated the request
     * @param _request The [`DecreasePositionRequest`](#decreasepositionrequest) struct containing decrease position details.
     * @return cmds_ An array of [`Command`](../../Command.sol/struct.Command.html) to execute the request.
     */
    function evaluate(
        address _operator,
        DecreasePositionRequest calldata _request
    ) external returns (Command[] memory cmds_);
}
"
    },
    "contracts/interfaces/compiler/adapters/IExchangeEvaluator.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

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

/**
 * @title IExchangeEvaluator
 * @notice Interface for compiling commands for token exchanges for different protocols.
 */
interface IExchangeEvaluator {
    /**
     * @notice Structure for an exchange token request.
     * @dev `path`: Encoded path of tokens to follow in the exchange, including pool identifiers.
     * 20 bytes(tokenA) + 4 byte(poolId_A_B) + 20 bytes(tokenB) + ...
     * ... + 4 byte(poolId_N-1_N) + 20 bytes(tokenN).
     * @dev `extraData`: Additional data specific to a particular protocol, such as the response from a 1Inch Exchange API.
     * @dev `amountIn`: The amount of tokenA to spend.
     * @dev `minAmountOut`: The minimum amount of tokenN to receive.
     * @dev `recipient`: The recipient of tokenN.
     */
    struct ExchangeRequest {
        bytes path;
        bytes extraData;
        uint256 amountIn;
        uint256 minAmountOut;
        address recipient;
    }

    /**
     * @notice Constructs an exchange token request.
     * @param _operator Address which initiated the request
     * @param _request The [`ExchangeRequest`](#exchangerequest) struct containing exchange token details.
     * @return cmds_ An array of [`Command`](../../Command.sol/struct.Command.html) to execute the request.
     */
    function evaluate(
        address _operator,
        ExchangeRequest calldata _request
    ) external view returns (Command[] memory cmds_);
}
"
    },
    "contracts/interfaces/compiler/adapters/IIncreasePositionEvaluator.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

import {Asset} from "contracts/libraries/AssetLibrary.sol";
import {Command} from "../Command.sol";
import {PositionDescriptor} from "./PositionDescriptor.sol";

interface IIncreasePositionEvaluator {
    /**
     * @notice Structure for an increase position request.
     * @dev `descriptor`: The [`PositionDescriptor`](/interfaces/compiler/adapters/PositionDescriptor.sol/struct.PositionDescriptor.html)
     *  struct.
     * @dev `input`: An array of [`Asset`](/interfaces/compliance/Asset.sol/struct.Asset.html) representing the token-amounts that will be added to the position.
     * @dev `minLiquidityOut`: An abstract amount that can be interpreted differently in different protocols (e.g., minimum amount of LP tokens to receive).
     */
    struct IncreasePositionRequest {
        PositionDescriptor descriptor;
        Asset[] input;
        uint256 minLiquidityOut;
    }

    /**
     * @notice Evaluate a increase position request.
     * @param _operator Address which initiated the request
     * @param _request The [`IncreasePositionRequest`](#increasepositionrequest) struct containing increase position details.
     * @return cmds_ An array of [`Command`](../../Command.sol/struct.Command.html) to execute the request.
     */
    function evaluate(
        address _operator,
        IncreasePositionRequest calldata _request
    ) external returns (Command[] memory cmds_);
}
"
    },
    "contracts/interfaces/compiler/adapters/PositionDescriptor.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

// TODO CRYPTO-145: Possibly move into appropriate interface?
/**
 * @notice Used to determine the required position for an operation.
 * @dev `poolId`: An identifier that is unique within a single protocol.
 * @dev `extraData`: Additional data used to specify the position, for example
 * this is used in OneInchV5Evaluator to pass swap tx generated via 1inch API.
 */
struct PositionDescriptor {
    uint256 poolId;
    bytes extraData;
}
"
    },
    "contracts/interfaces/compiler/Command.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

import {CommandLibrary} from "contracts/libraries/CommandLibrary.sol";

/**
 * @title Command
 * @notice Contains arguments for a low-level call.
 * @dev This struct allows deferring the call's execution, suspending it by passing it to another function or contract.
 * @dev `target` The address to be called.
 * @dev `value` Value to send in the call.
 * @dev `payload` Encoded call with function selector and arguments.
 */
struct Command {
    address target;
    uint256 value;
    bytes payload;
}

using CommandLibrary for Command global;
"
    },
    "contracts/interfaces/compiler/IJitCompiler.sol": {
      "content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.22;

import {IERC165Extended} from "contracts/interfaces/base/IERC165Extended.sol";

import {IDecreasePositionEvaluator} from "./adapters/IDecreasePositionEvaluator.sol";
import {IExchangeEvaluator} from "./adapters/IExchangeEvaluator.sol";
import {IIncreasePositionEvaluator} from "./adapters/IIncreasePositionEvaluator.sol";
import {Command} from "./Command.sol";
import {Script} from "./Script.sol";

/**
 * @title IJitCompiler
 * @notice Compiles a script or an instruction into an array of [Commands](/interfaces/compiler/Command.sol/struct.Command.html) using protocol evaluator matching `protocol` field in the underlying instruction.
 */
interface IJitCompiler is IERC165Extended {
    /**
     * @notice Instruction designed to increase:
     *  1. Caller's magnitude of the position determined by the [PositionDescriptor](../adapters/PositionDescriptor.sol/struct.PositionDescriptor.html).
     *  2. Callee's balance of token(s).
     * @notice and decrease:
     *  1. Caller's balance of token(s).
     *  2. (*Optional*) callee's supply of the position determined by the [PositionDescriptor](../adapters/PositionDescriptor.sol/struct.PositionDescriptor.html).
     * @dev This instruction will be evaluated in [IncreasePositionEvaluator](../adapters/IIncreasePositionEvaluator.sol/interface.IIncreasePositionEvaluator.html).
     * @dev `protocol` The name of the underlying protocol where instruction should be evaluated. For example: `curvefi`, `oneinchv5`
     * @dev `request` The [`IncreasePositionRequest`](../adapters/IIncreasePositionEvaluator.sol/interface.IIncreasePositionEvaluator.html#increasepositionrequest) containing all information required for instruction evaluation.
     */
    struct IncreasePositionInstruction {
        string protocol;
        IIncreasePositionEvaluator.IncreasePositionRequest request;
    }

    /**
     * @notice Instruction designed to increase:
     *  1. Caller's balance of token(s).
     *  2. (*Optional*) callee's supply of the position determined by the [PositionDescriptor](../adapters/PositionDescriptor.sol/struct.PositionDescriptor.html).
     * @notice and decrease:
     *  1. Caller's magnitude of the position determined by the [PositionDescriptor](../adapters/PositionDescriptor.sol/struct.PositionDescriptor.html).
     *  2. Callee's balance of token(s).
     * @dev This instruction will be evaluated in [DecreasePositionEvaluator](../adapters/IDecreasePositionEvaluator.sol/interface.IDecreasePositionEvaluator.html).
     * @dev `protocol` The name of the underlying protocol where instruction should be evaluated. For example: `curvefi`, `oneinchv5`
     * @dev `request` The [`DecreasePositionRequest`](../adapters/IDecreasePositionEvaluator.sol/interface.IDecreasePositionEvaluator.html#decreasepositionrequest) containing all information required for instruction evaluation.
     */
    struct DecreasePositionInstruction {
        string protocol;
        IDecreasePositionEvaluator.DecreasePositionRequest request;
    }

    /**
     * @notice Instruction designed to increase:
     *  1. (*Optional*) caller's balance of output token.
     *  2. Callee's balance of input token.
     * @notice and decrease:
     *  1. Caller's balance of input token.
     *  2. (*Optional*) callee's balance of output token.
     * @dev This instruction will be evaluated in [ExchangeEvaluator](../adapters/IExchangeEvaluator.sol/interface.IExchangeEvaluator.html).
     * @dev `protocol` The name of the underlying protocol where instruction should be evaluated. For example: `curvefi`, `oneinchv5`
     * @dev `request` The [`ExchangeRequest`](../adapters/IExchangeEvaluator.sol/interface.IExchangeEvaluator.html#exchangerequest) containing all information required for instruction evaluation.
     */
    struct ExchangeInstruction {
        string protocol;
        IExchangeEvaluator.ExchangeRequest request;
    }

    /**
     * @notice Instruction designed to increase:
     *  1. (*Optional*) caller's balance of output token.
     *  2. Callee's balance of input token.
     * @notice and decrease:
     *  1. Caller's balance of input token.
     *  2. (*Optional*) callee's balance of output token.
     * @dev This instruction will be evaluated in [ExchangeEvaluator](../adapters/IExchangeEvaluator.sol/interface.IExchangeEvaluator.html).
     * @dev **Important note:** this instruction has an identical structure to [ExchangeInstruction](#exchangeinstruction), but differs from it in that [ExchangeInstruction](#exchangeinstruction) is static and [ExchangeAllInstruction](#exchangeallinstruction) is dynamic. This means that the `amountIn` field will be set at runtime by the compiler to the caller's balance by the input token.
     * @dev `protocol` The name of the underlying protocol where instruction should be evaluated. For example: `curvefi`, `oneinchv5`
     * @dev `request` The [`ExchangeRequest`](../adapters/IExchangeEvaluator.sol/interface.IExchangeEvaluator.html#exchangerequest) containing all information required for instruction evaluation. The `amountIn` field will be set at runtime by the compiler to the caller's balance by the input token.
     */
    struct ExchangeAllInstruction {
        string protocol;
        IExchangeEvaluator.ExchangeRequest request;
    }

    /**
     * @notice Compiles a [Script](../Script.sol/struct.Script.html).
     * @dev **Important note:** don't put two instructions to the same script if one depend on the other because content of the script will be compiled at once meaning that balance changes will be applied only after the compilation of the entire script. If you have two instructions and one depends on the other, put them into different scripts.
     * @param script Script to compile
     * @return An array of [`Commands`](../Command.sol/struct.Command.html) to execute the instruction.
     */
    function compile(Script calldata script) external returns (Co

Tags:
ERC20, ERC165, Multisig, Pausable, Swap, Liquidity, Upgradeable, Multi-Signature, Factory|addr:0xce422e62c8f774f68c2f810e026e1b28f2f6cb76|verified:true|block:23575286|tx:0x072ec6564738627734c64f9b00191d41b1a8e26c89a9f70b96121d7cfa37833d|first_check:1760437265

Submitted on: 2025-10-14 12:21:06

Comments

Log in to comment.

No comments yet.