| 1 | // SPDX-License-Identifier: MIT |
| 2 | pragma solidity >=0.6.2; |
| 3 | |
| 4 | import {IERC7575} from "./IERC7575.sol"; |
| 5 | |
| 6 | /// @dev Interface of the base operator logic of ERC7540, as defined in |
| 7 | /// https://eips.ethereum.org/EIPS/eip-7540 |
| 8 | interface IERC7540Operator { |
| 9 | /** |
| 10 | * @dev The event emitted when an operator is set. |
| 11 | * |
| 12 | * @param controller The address of the controller. |
| 13 | * @param operator The address of the operator. |
| 14 | * @param approved The approval status. |
| 15 | */ |
| 16 | event OperatorSet(address indexed controller, address indexed operator, bool approved); |
| 17 | |
| 18 | /** |
| 19 | * @dev Sets or removes an operator for the caller. |
| 20 | * |
| 21 | * @param operator The address of the operator. |
| 22 | * @param approved The approval status. |
| 23 | * @return Whether the call was executed successfully or not |
| 24 | */ |
| 25 | function setOperator(address operator, bool approved) external returns (bool); |
| 26 | |
| 27 | /** |
| 28 | * @dev Returns `true` if the `operator` is approved as an operator for an `controller`. |
| 29 | * |
| 30 | * @param controller The address of the controller. |
| 31 | * @param operator The address of the operator. |
| 32 | * @return status The approval status |
| 33 | */ |
| 34 | function isOperator(address controller, address operator) external view returns (bool status); |
| 35 | } |
| 36 | |
| 37 | /// @dev Interface of the asynchronous deposit Vault interface of ERC7540, as defined in |
| 38 | /// https://eips.ethereum.org/EIPS/eip-7540 |
| 39 | interface IERC7540Deposit is IERC7540Operator { |
| 40 | event DepositRequest( |
| 41 | address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets |
| 42 | ); |
| 43 | /** |
| 44 | * @dev Transfers assets from sender into the Vault and submits a Request for asynchronous deposit. |
| 45 | * |
| 46 | * - MUST support ERC-20 approve / transferFrom on asset as a deposit Request flow. |
| 47 | * - MUST revert if all of assets cannot be requested for deposit. |
| 48 | * - owner MUST be msg.sender unless some unspecified explicit approval is given by the caller, |
| 49 | * approval of ERC-20 tokens from owner to sender is NOT enough. |
| 50 | * |
| 51 | * @param assets the amount of deposit assets to transfer from owner |
| 52 | * @param controller the controller of the request who will be able to operate the request |
| 53 | * @param owner the source of the deposit assets |
| 54 | * |
| 55 | * NOTE: most implementations will require pre-approval of the Vault with the Vault's underlying asset token. |
| 56 | */ |
| 57 | |
| 58 | function requestDeposit(uint256 assets, address controller, address owner) external returns (uint256 requestId); |
| 59 | |
| 60 | /** |
| 61 | * @dev Returns the amount of requested assets in Pending state. |
| 62 | * |
| 63 | * - MUST NOT include any assets in Claimable state for deposit or mint. |
| 64 | * - MUST NOT show any variations depending on the caller. |
| 65 | * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. |
| 66 | */ |
| 67 | function pendingDepositRequest(uint256 requestId, address controller) |
| 68 | external |
| 69 | view |
| 70 | returns (uint256 pendingAssets); |
| 71 | |
| 72 | /** |
| 73 | * @dev Returns the amount of requested assets in Claimable state for the controller to deposit or mint. |
| 74 | * |
| 75 | * - MUST NOT include any assets in Pending state. |
| 76 | * - MUST NOT show any variations depending on the caller. |
| 77 | * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. |
| 78 | */ |
| 79 | function claimableDepositRequest(uint256 requestId, address controller) |
| 80 | external |
| 81 | view |
| 82 | returns (uint256 claimableAssets); |
| 83 | |
| 84 | /** |
| 85 | * @dev Mints shares Vault shares to receiver by claiming the Request of the controller. |
| 86 | * |
| 87 | * - MUST emit the Deposit event. |
| 88 | * - controller MUST equal msg.sender unless the controller has approved the msg.sender as an operator. |
| 89 | */ |
| 90 | function deposit(uint256 assets, address receiver, address controller) external returns (uint256 shares); |
| 91 | |
| 92 | /** |
| 93 | * @dev Mints exactly shares Vault shares to receiver by claiming the Request of the controller. |
| 94 | * |
| 95 | * - MUST emit the Deposit event. |
| 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 | /// @dev Interface of the asynchronous deposit Vault interface of ERC7540, as defined in |
| 102 | /// https://eips.ethereum.org/EIPS/eip-7540 |
| 103 | interface IERC7540Redeem is IERC7540Operator { |
| 104 | event RedeemRequest( |
| 105 | address indexed controller, address indexed owner, uint256 indexed requestId, address sender, uint256 assets |
| 106 | ); |
| 107 | |
| 108 | /** |
| 109 | * @dev Assumes control of shares from sender into the Vault and submits a Request for asynchronous redeem. |
| 110 | * |
| 111 | * - MUST support a redeem Request flow where the control of shares is taken from sender directly |
| 112 | * where msg.sender has ERC-20 approval over the shares of owner. |
| 113 | * - MUST revert if all of shares cannot be requested for redeem. |
| 114 | * |
| 115 | * @param shares the amount of shares to be redeemed to transfer from owner |
| 116 | * @param controller the controller of the request who will be able to operate the request |
| 117 | * @param owner the source of the shares to be redeemed |
| 118 | * |
| 119 | * NOTE: most implementations will require pre-approval of the Vault with the Vault's share token. |
| 120 | */ |
| 121 | function requestRedeem(uint256 shares, address controller, address owner) external returns (uint256 requestId); |
| 122 | |
| 123 | /** |
| 124 | * @dev Returns the amount of requested shares in Pending state. |
| 125 | * |
| 126 | * - MUST NOT include any shares in Claimable state for redeem or withdraw. |
| 127 | * - MUST NOT show any variations depending on the caller. |
| 128 | * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. |
| 129 | */ |
| 130 | function pendingRedeemRequest(uint256 requestId, address controller) |
| 131 | external |
| 132 | view |
| 133 | returns (uint256 pendingShares); |
| 134 | |
| 135 | /** |
| 136 | * @dev Returns the amount of requested shares in Claimable state for the controller to redeem or withdraw. |
| 137 | * |
| 138 | * - MUST NOT include any shares in Pending state for redeem or withdraw. |
| 139 | * - MUST NOT show any variations depending on the caller. |
| 140 | * - MUST NOT revert unless due to integer overflow caused by an unreasonably large input. |
| 141 | */ |
| 142 | function claimableRedeemRequest(uint256 requestId, address controller) |
| 143 | external |
| 144 | view |
| 145 | returns (uint256 claimableShares); |
| 146 | } |
| 147 | |
| 148 | /// @dev Interface of the fully asynchronous Vault interface of ERC7540, as defined in |
| 149 | /// https://eips.ethereum.org/EIPS/eip-7540 |
| 150 | interface IERC7540 is IERC7540Deposit, IERC7540Redeem, IERC7575 {} |