DepositController
Inherits: Base, IDepositController
This smart contract is responsible for managing the deposit process of a tranche pool in a portfolio. It handles the distribution of shares and fees when depositing assets and minting shares. The main functions include calculating the number of shares for a given deposit amount, estimating the total assets for a given number of shares, determining the maximum deposit amount and maximum mintable shares based on a given ceiling, and setting the deposit fee rate. This contract works in conjunction with the TranchePool contract to manage deposits and maintain the portfolio.
State Variables
depositFeeRate
uint256 public depositFeeRate;
BASIS_PRECISION
uint256 constant BASIS_PRECISION = 10_000;
Functions
constructor
constructor(
IProtocolConfig _protocolConfig,
address _manager,
uint256 _depositFeeRate
)
Base(_protocolConfig.protocolAdmin(), _protocolConfig.pauser());
onDeposit
Handle deposit of assets and distribute shares and fees accordingly
function onDeposit(address, uint256 assets, address receiver) external returns (uint256 shares, uint256 fees);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
assets | uint256 | The amount of assets being deposited |
receiver | address | The address receiving the shares |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares minted for the deposit |
fees | uint256 | The amount of fees collected during the deposit |
onMint
Handle minting of shares and distribute assets and fees accordingly
function onMint(address, uint256 shares, address receiver) external returns (uint256 assets, uint256 fees);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
shares | uint256 | The amount of shares being minted |
receiver | address | The address receiving the assets |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets corresponding to the minted shares |
fees | uint256 | The amount of fees collected during the minting |
previewDeposit
Preview the number of shares that will be minted for a given amount of assets
function previewDeposit(uint256 assets) public view returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets to be deposited |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The estimated number of shares to be minted |
previewMint
Preview the total amount of assets (including fees) for a given number of shares
function previewMint(uint256 shares) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares to be minted |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets The estimated total amount of assets (including fees) for the given shares |
maxDeposit
Calculate the maximum deposit amount based on the given ceiling
function maxDeposit(address, uint256 ceiling) public view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
ceiling | uint256 | The maximum allowed total assets |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | assets The maximum deposit amount under the given ceiling |
maxMint
Calculate the maximum number of shares that can be minted based on the given ceiling
function maxMint(address receiver, uint256 ceiling) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
receiver | address | The address receiving the assets |
ceiling | uint256 | The maximum allowed total assets |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares The maximum number of shares that can be minted under the given ceiling |
setDepositFeeRate
Set the deposit fee rate
function setDepositFeeRate(uint256 _depositFeeRate) external;
Parameters
Name | Type | Description |
---|---|---|
_depositFeeRate | uint256 | The new deposit fee rate |
_calculateDepositFee
function _calculateDepositFee(uint256 assets) internal view returns (uint256);
_calculateMaxDeposit
function _calculateMaxDeposit(uint256 assets) internal view returns (uint256);