DepositController

Git Source

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

NameTypeDescription
<none>address
assetsuint256The amount of assets being deposited
receiveraddressThe address receiving the shares

Returns

NameTypeDescription
sharesuint256The amount of shares minted for the deposit
feesuint256The 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

NameTypeDescription
<none>address
sharesuint256The amount of shares being minted
receiveraddressThe address receiving the assets

Returns

NameTypeDescription
assetsuint256The amount of assets corresponding to the minted shares
feesuint256The 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

NameTypeDescription
assetsuint256The amount of assets to be deposited

Returns

NameTypeDescription
sharesuint256The 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

NameTypeDescription
sharesuint256The amount of shares to be minted

Returns

NameTypeDescription
<none>uint256assets 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

NameTypeDescription
<none>address
ceilinguint256The maximum allowed total assets

Returns

NameTypeDescription
<none>uint256assets 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

NameTypeDescription
receiveraddressThe address receiving the assets
ceilinguint256The maximum allowed total assets

Returns

NameTypeDescription
<none>uint256shares 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

NameTypeDescription
_depositFeeRateuint256The new deposit fee rate

_calculateDepositFee

function _calculateDepositFee(uint256 assets) internal view returns (uint256);

_calculateMaxDeposit

function _calculateMaxDeposit(uint256 assets) internal view returns (uint256);