|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.20; |
| 3 | + |
| 4 | +/// @title IRequest |
| 5 | +/// @notice Interface for handling token consumption, repayment, and validation logic in a request system. |
| 6 | +/// @dev This is the interface expected to intereact with the position manager to: |
| 7 | +/// - Account for remaining debt |
| 8 | +/// - Consume and repay the request token |
| 9 | +/// - Validate the request token and the consumer address |
| 10 | +interface IRequest { |
| 11 | + /** |
| 12 | + * @notice Consumes a specified amount of the request token and sends it to the given receiver address. |
| 13 | + * @dev After a repayment has been initiated, no further consumption can take place. |
| 14 | + * Requirements and expected state transitions are implementation-specific. |
| 15 | + * @dev The amount of consumed tokens should not be greater than the principal assets amount. |
| 16 | + * @param amount The amount of the request token to consume. |
| 17 | + * @param receiver The address that will receive the consumed tokens. |
| 18 | + */ |
| 19 | + function consume(uint256 amount, address receiver) external; |
| 20 | + |
| 21 | + /** |
| 22 | + * @notice Repays a specified amount of the request token. |
| 23 | + * @dev This operation records repayment against the outstanding balance. |
| 24 | + * After any call to {repay}, no further consumption is allowed. |
| 25 | + * Only callable if full repayment has not yet been validated. |
| 26 | + * It should pull from the caller's balance. |
| 27 | + * @param amount The amount of the request token to repay. |
| 28 | + */ |
| 29 | + function repay(uint256 amount) external; |
| 30 | + |
| 31 | + /** |
| 32 | + * @notice Validates and finalizes the state that the full repayment of the request token has been made. |
| 33 | + * @dev This function locks the contract against further repayments or consumptions, |
| 34 | + * and may enable a new phase in the workflow. Only callable if the amount repaid |
| 35 | + * matches the total amount required. |
| 36 | + */ |
| 37 | + function validateFullRepayment() external; |
| 38 | + |
| 39 | + /** |
| 40 | + * @notice Returns the total amount of principal tokens that have been consumed. |
| 41 | + * @return The total amount of principal tokens that have been consumed. |
| 42 | + */ |
| 43 | + function principalSupply() external view returns (uint256); |
| 44 | + |
| 45 | + /** |
| 46 | + * @notice Returns the total amount of principal assets that have been repaid. |
| 47 | + * @return The total amount of principal assets that have been repaid. |
| 48 | + */ |
| 49 | + function principalAssets() external view returns (uint256); |
| 50 | + |
| 51 | + /** |
| 52 | + * @notice Returns the total amount of yield tokens that have been consumed. |
| 53 | + * @return The total amount of yield tokens that have been consumed. |
| 54 | + */ |
| 55 | + function yieldSupply() external view returns (uint256); |
| 56 | + |
| 57 | + /** |
| 58 | + * @notice Returns the total amount of yield assets that have been repaid. |
| 59 | + * @return The total amount of yield assets that have been repaid. |
| 60 | + */ |
| 61 | + function yieldAssets() external view returns (uint256); |
| 62 | + |
| 63 | + /** |
| 64 | + * @notice Returns the address of the ERC-20 token underlying this request. |
| 65 | + * @dev The returned address should reference the token contract used for consumption and repayment. |
| 66 | + * @return token The address of the request token used by this contract. |
| 67 | + */ |
| 68 | + function token() external view returns (address token); |
| 69 | + |
| 70 | + /** |
| 71 | + * @notice Returns the address of the consumer of this request. |
| 72 | + * @return consumer The address of the consumer of this request. |
| 73 | + */ |
| 74 | + function consumer() external view returns (address consumer); |
| 75 | +} |
0 commit comments