|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | + |
| 3 | +pragma solidity >=0.8.4; |
| 4 | + |
| 5 | +import {IERC7575} from "./IERC7575.sol"; |
| 6 | + |
| 7 | +/** |
| 8 | + * @dev Interface for operator management in https://eips.ethereum.org/EIPS/eip-7540[ERC-7540] |
| 9 | + * asynchronous vaults. Operators can manage deposit and redeem requests on behalf of a controller. |
| 10 | + */ |
| 11 | +interface IERC7540Operator { |
| 12 | + /// @dev Emitted when `controller` sets the `approved` status for an `operator`. |
| 13 | + event OperatorSet(address indexed controller, address indexed operator, bool approved); |
| 14 | + |
| 15 | + /** |
| 16 | + * @dev Grants or revokes permissions for `operator` to manage requests on behalf of the caller. |
| 17 | + * |
| 18 | + * - MUST set the operator status to the `approved` value. |
| 19 | + * - MUST emit the {OperatorSet} event when the operator status is set. |
| 20 | + * - MUST return true. |
| 21 | + */ |
| 22 | + function setOperator(address operator, bool approved) external returns (bool); |
| 23 | + |
| 24 | + /// @dev Returns `true` if the `operator` is approved as an operator for a `controller`. |
| 25 | + function isOperator(address controller, address operator) external view returns (bool status); |
| 26 | +} |
| 27 | + |
| 28 | +/** |
| 29 | + * @dev Interface for asynchronous deposit requests in https://eips.ethereum.org/EIPS/eip-7540[ERC-7540] |
| 30 | + * vaults. Enables users to request deposits that transition through Pending and Claimable states |
| 31 | + * before being claimed via the standard ERC-4626 deposit/mint functions. |
| 32 | + */ |
| 33 | +interface IERC7540Deposit { |
| 34 | + /** |
| 35 | + * @dev Emitted when `owner` has locked `assets` in the Vault to request a deposit. |
| 36 | + * `controller` controls this request. `sender` is the caller of `requestDeposit`. |
| 37 | + */ |
| 38 | + event DepositRequest( |
| 39 | + address indexed controller, |
| 40 | + address indexed owner, |
| 41 | + uint256 indexed requestId, |
| 42 | + address sender, |
| 43 | + uint256 assets |
| 44 | + ); |
| 45 | + |
| 46 | + /** |
| 47 | + * @dev Transfers `assets` from `owner` into the Vault and submits a request for asynchronous deposit. |
| 48 | + * |
| 49 | + * - MUST support ERC-20 approve / transferFrom on `asset` as a deposit request flow. |
| 50 | + * - `owner` MUST equal `msg.sender` unless the `owner` has approved the `msg.sender` as an operator. |
| 51 | + * - MUST revert if all of `assets` cannot be requested for deposit. |
| 52 | + * - MUST emit the {DepositRequest} event. |
| 53 | + * |
| 54 | + * NOTE: Most implementations will require `owner` to have approved the Vault to spend at least `assets` of |
| 55 | + * the underlying asset token (e.g. via `asset.approve(vault, assets)`) before calling this function. |
| 56 | + */ |
| 57 | + function requestDeposit(uint256 assets, address controller, address owner) external returns (uint256 requestId); |
| 58 | + |
| 59 | + /** |
| 60 | + * @dev Returns the amount of requested assets in Pending state. |
| 61 | + * |
| 62 | + * - MUST NOT include any assets in Claimable state for deposit or mint. |
| 63 | + * - MUST NOT show any variations depending on the caller. |
| 64 | + * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. |
| 65 | + */ |
| 66 | + function pendingDepositRequest(uint256 requestId, address controller) external view returns (uint256 pendingAssets); |
| 67 | + |
| 68 | + /** |
| 69 | + * @dev Returns the amount of requested assets in Claimable state for the controller to deposit or mint. |
| 70 | + * |
| 71 | + * - MUST NOT include any assets in Pending state. |
| 72 | + * - MUST NOT show any variations depending on the caller. |
| 73 | + * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. |
| 74 | + */ |
| 75 | + function claimableDepositRequest( |
| 76 | + uint256 requestId, |
| 77 | + address controller |
| 78 | + ) external view returns (uint256 claimableAssets); |
| 79 | + |
| 80 | + /** |
| 81 | + * @dev Claims a pending deposit request by minting shares to receiver. |
| 82 | + * Decreases `claimableDepositRequest` for the controller and transfers shares to receiver. |
| 83 | + * |
| 84 | + * - MUST emit the Deposit event. |
| 85 | + * - MUST revert if controller does not have sufficient claimable assets. |
| 86 | + * - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator. |
| 87 | + */ |
| 88 | + function deposit(uint256 assets, address receiver, address controller) external returns (uint256 shares); |
| 89 | + |
| 90 | + /** |
| 91 | + * @dev Claims a pending deposit request by minting exactly shares to receiver. |
| 92 | + * Decreases `claimableDepositRequest` for the controller and transfers shares to receiver. |
| 93 | + * |
| 94 | + * - MUST emit the Deposit event. |
| 95 | + * - MUST revert if controller does not have sufficient claimable assets. |
| 96 | + * - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator. |
| 97 | + */ |
| 98 | + function mint(uint256 shares, address receiver, address controller) external returns (uint256 assets); |
| 99 | +} |
| 100 | + |
| 101 | +/** |
| 102 | + * @dev Interface for asynchronous redeem requests in https://eips.ethereum.org/EIPS/eip-7540[ERC-7540] |
| 103 | + * vaults. Enables users to request redemptions that transition through Pending and Claimable states |
| 104 | + * before being claimed via the standard ERC-4626 redeem/withdraw functions. |
| 105 | + */ |
| 106 | +interface IERC7540Redeem { |
| 107 | + /** |
| 108 | + * @dev Emitted when `sender` has locked `shares`, owned by `owner`, in the Vault to request a redemption. |
| 109 | + * `controller` controls this request. |
| 110 | + */ |
| 111 | + event RedeemRequest( |
| 112 | + address indexed controller, |
| 113 | + address indexed owner, |
| 114 | + uint256 indexed requestId, |
| 115 | + address sender, |
| 116 | + uint256 shares |
| 117 | + ); |
| 118 | + |
| 119 | + /** |
| 120 | + * @dev Assumes control of shares from owner into the Vault and submits a request for asynchronous redeem. |
| 121 | + * |
| 122 | + * Authorization for a `msg.sender` not equal to `owner` may come either from ERC-20 approval over |
| 123 | + * the shares of `owner` or from an operator approval via {IERC7540Operator-setOperator}. Operators |
| 124 | + * are not subject to allowance restrictions, while non-infinite ERC-20 approvals are consumed. |
| 125 | + * |
| 126 | + * - MUST revert if all of shares cannot be requested for redeem. |
| 127 | + * - MUST emit the {RedeemRequest} event. |
| 128 | + * |
| 129 | + * NOTE: Most implementations will require `owner` to have approved the Vault to spend at least `shares` of |
| 130 | + * the Vault's share token (e.g. via `share.approve(vault, shares)`) before calling this function. |
| 131 | + */ |
| 132 | + function requestRedeem(uint256 shares, address controller, address owner) external returns (uint256 requestId); |
| 133 | + |
| 134 | + /** |
| 135 | + * @dev Returns the amount of requested shares in Pending state. |
| 136 | + * |
| 137 | + * - MUST NOT include any shares in Claimable state for redeem or withdraw. |
| 138 | + * - MUST NOT show any variations depending on the caller. |
| 139 | + * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. |
| 140 | + */ |
| 141 | + function pendingRedeemRequest(uint256 requestId, address controller) external view returns (uint256 pendingShares); |
| 142 | + |
| 143 | + /** |
| 144 | + * @dev Returns the amount of requested shares in Claimable state for the controller to redeem or withdraw. |
| 145 | + * |
| 146 | + * - MUST NOT include any shares in Pending state for redeem or withdraw. |
| 147 | + * - MUST NOT show any variations depending on the caller. |
| 148 | + * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. |
| 149 | + */ |
| 150 | + function claimableRedeemRequest( |
| 151 | + uint256 requestId, |
| 152 | + address controller |
| 153 | + ) external view returns (uint256 claimableShares); |
| 154 | +} |
| 155 | + |
| 156 | +/** |
| 157 | + * @dev Interface of the fully asynchronous Vault interface of ERC7540, as defined in |
| 158 | + * https://eips.ethereum.org/EIPS/eip-7540 |
| 159 | + */ |
| 160 | +interface IERC7540 is IERC7540Operator, IERC7540Deposit, IERC7540Redeem, IERC7575 {} |
0 commit comments