|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | + |
| 3 | +pragma solidity ^0.8.16; |
| 4 | + |
| 5 | +import {ILenderVerifier} from "../carbon/interfaces/ILenderVerifier.sol"; |
| 6 | +import {Status} from "../carbon/interfaces/IStructuredPortfolio.sol"; |
| 7 | +import {DepositAllowed} from "../carbon/interfaces/IDepositController.sol"; |
| 8 | + |
| 9 | +/** |
| 10 | + * @title Contract for managing deposit related settings |
| 11 | + * @dev Used by TrancheVault contract |
| 12 | + */ |
| 13 | +interface IDepositController { |
| 14 | + /** |
| 15 | + * @notice Event emitted when new ceiling is set |
| 16 | + * @param newCeiling New ceiling value |
| 17 | + */ |
| 18 | + event CeilingChanged(uint256 newCeiling); |
| 19 | + |
| 20 | + /** |
| 21 | + * @notice Event emitted when deposits are disabled or enabled for a specific StructuredPortfolio status |
| 22 | + * @param newDepositAllowed Value indicating whether deposits should be enabled or disabled |
| 23 | + * @param portfolioStatus StructuredPortfolio status for which changes are applied |
| 24 | + */ |
| 25 | + event DepositAllowedChanged(bool newDepositAllowed, Status portfolioStatus); |
| 26 | + |
| 27 | + /** |
| 28 | + * @notice Event emitted when deposit fee rate is switched |
| 29 | + * @param newFeeRate New deposit fee rate value (in BPS) |
| 30 | + */ |
| 31 | + event DepositFeeRateChanged(uint256 newFeeRate); |
| 32 | + |
| 33 | + /** |
| 34 | + * @notice Event emitted when minimum deposit is changed |
| 35 | + * @param newMinimumDeposit New minimum deposit value (in assets) |
| 36 | + */ |
| 37 | + event MinimumDepositChanged(uint256 newMinimumDeposit); |
| 38 | + |
| 39 | + /** |
| 40 | + * @notice Event emitted when lender verifier is switched |
| 41 | + * @param newLenderVerifier New lender verifier contract address |
| 42 | + */ |
| 43 | + event LenderVerifierChanged(ILenderVerifier indexed newLenderVerifier); |
| 44 | + |
| 45 | + /// @return DepositController manager role used for access control |
| 46 | + function MANAGER_ROLE() external view returns (bytes32); |
| 47 | + |
| 48 | + /// @return Address of contract used for checking whether given address is allowed to put funds into an instrument according to implemented strategy |
| 49 | + function lenderVerifier() external view returns (ILenderVerifier); |
| 50 | + |
| 51 | + /// @return Max asset capacity defined for TrancheVaults interacting with DepositController |
| 52 | + function ceiling() external view returns (uint256); |
| 53 | + |
| 54 | + /// @return Rate (in BPS) of the fee applied to the deposit amount |
| 55 | + function depositFeeRate() external view returns (uint256); |
| 56 | + |
| 57 | + /// @return Value indicating whether deposits are allowed when related StructuredPortfolio is in given status |
| 58 | + /// @param status StructuredPortfolio status |
| 59 | + function depositAllowed(Status status) external view returns (bool); |
| 60 | + |
| 61 | + /** |
| 62 | + * @notice Setup contract with given params |
| 63 | + * @dev Used by Initializable contract (can be called only once) |
| 64 | + * @param manager Address to which MANAGER_ROLE should be granted |
| 65 | + * @param _lenderVerifier Address of LenderVerifier contract |
| 66 | + * @param _depositFeeRate Deposit fee rate (in BPS) |
| 67 | + * @param _minimumDeposit Minimum deposit value (in assets) |
| 68 | + * @param _ceiling Ceiling value |
| 69 | + */ |
| 70 | + function initialize( |
| 71 | + address manager, |
| 72 | + address _lenderVerifier, |
| 73 | + uint256 _depositFeeRate, |
| 74 | + uint256 _minimumDeposit, |
| 75 | + uint256 _ceiling |
| 76 | + ) external; |
| 77 | + |
| 78 | + /** |
| 79 | + * @return assets Max assets amount that can be deposited with TrancheVault shares minted to given receiver |
| 80 | + * @param receiver Shares receiver address |
| 81 | + */ |
| 82 | + function maxDeposit(address receiver) external view returns (uint256 assets); |
| 83 | + |
| 84 | + /** |
| 85 | + * @return shares Max TrancheVault shares amount given address can receive |
| 86 | + * @param receiver Shares receiver address |
| 87 | + */ |
| 88 | + function maxMint(address receiver) external view returns (uint256 shares); |
| 89 | + |
| 90 | + /** |
| 91 | + * @notice Simulates deposit assets conversion including fees |
| 92 | + * @return shares Shares amount that can be obtained from the given assets amount |
| 93 | + * @param assets Tested assets amount |
| 94 | + */ |
| 95 | + function previewDeposit(uint256 assets) external view returns (uint256 shares); |
| 96 | + |
| 97 | + /** |
| 98 | + * @notice Simulates mint shares conversion including fees |
| 99 | + * @return assets Assets amount that needs to be deposited to obtain given shares amount |
| 100 | + * @param shares Tested shares amount |
| 101 | + */ |
| 102 | + function previewMint(uint256 shares) external view returns (uint256 assets); |
| 103 | + |
| 104 | + /** |
| 105 | + * @notice Simulates deposit result |
| 106 | + * @return shares Shares amount that can be obtained from the deposit with given params |
| 107 | + * @return depositFee Fee for a deposit with given params |
| 108 | + * @param sender Supposed deposit transaction sender address |
| 109 | + * @param assets Supposed assets amount |
| 110 | + * @param receiver Supposed shares receiver address |
| 111 | + */ |
| 112 | + function onDeposit( |
| 113 | + address sender, |
| 114 | + uint256 assets, |
| 115 | + address receiver |
| 116 | + ) external returns (uint256 shares, uint256 depositFee); |
| 117 | + |
| 118 | + /** |
| 119 | + * @notice Simulates mint result |
| 120 | + * @return assets Assets amount that needs to be provided to execute mint with given params |
| 121 | + * @return mintFee Fee for a mint with given params |
| 122 | + * @param sender Supposed mint transaction sender address |
| 123 | + * @param shares Supposed shares amount |
| 124 | + * @param receiver Supposed shares receiver address |
| 125 | + */ |
| 126 | + function onMint( |
| 127 | + address sender, |
| 128 | + uint256 shares, |
| 129 | + address receiver |
| 130 | + ) external returns (uint256 assets, uint256 mintFee); |
| 131 | + |
| 132 | + /** |
| 133 | + * @notice Ceiling setter |
| 134 | + * @param newCeiling New ceiling value |
| 135 | + */ |
| 136 | + function setCeiling(uint256 newCeiling) external; |
| 137 | + |
| 138 | + /** |
| 139 | + * @notice Deposit allowed setter |
| 140 | + * @param newDepositAllowed Value indicating whether deposits should be allowed when related StructuredPortfolio is in given status |
| 141 | + * @param portfolioStatus StructuredPortfolio status for which changes are applied |
| 142 | + */ |
| 143 | + function setDepositAllowed(bool newDepositAllowed, Status portfolioStatus) external; |
| 144 | + |
| 145 | + /** |
| 146 | + * @notice Deposit fee rate setter |
| 147 | + * @param newFeeRate New deposit fee rate (in BPS) |
| 148 | + */ |
| 149 | + function setDepositFeeRate(uint256 newFeeRate) external; |
| 150 | + |
| 151 | + /** |
| 152 | + * @notice Lender verifier setter |
| 153 | + * @param newLenderVerifier New LenderVerifier contract address |
| 154 | + */ |
| 155 | + function setLenderVerifier(ILenderVerifier newLenderVerifier) external; |
| 156 | + |
| 157 | + /** |
| 158 | + * @notice Allows to change ceiling, deposit fee rate, minimum deposit, lender verifier and enable or disable deposits at once |
| 159 | + * @param newCeiling New ceiling value |
| 160 | + * @param newFeeRate New deposit fee rate (in BPS) |
| 161 | + * @param newMinimumDeposit New minimum deposit value (in assets) |
| 162 | + * @param newLenderVerifier New LenderVerifier contract address |
| 163 | + * @param newDepositAllowed New deposit allowed settings |
| 164 | + */ |
| 165 | + function configure( |
| 166 | + uint256 newCeiling, |
| 167 | + uint256 newFeeRate, |
| 168 | + uint256 newMinimumDeposit, |
| 169 | + ILenderVerifier newLenderVerifier, |
| 170 | + DepositAllowed memory newDepositAllowed |
| 171 | + ) external; |
| 172 | +} |
0 commit comments