WithdrawController
Inherits: Base, IWithdrawController
This smart contract is responsible for managing the withdrawal process of a tranche pool in a portfolio. It handles the calculation of withdrawal and redemption fees, as well as the withdrawal of assets and redemption of shares. The main functions include determining the maximum withdrawable assets and redeemable shares for a user, previewing the amount of shares to burn for a given asset withdrawal, estimating the amount of assets to receive after burning a given number of shares, and setting the withdrawal fee rate. This contract works in conjunction with the TranchePool contract to manage withdrawals and maintain the portfolio.
State Variables
withdrawFeeRate
uint256 public withdrawFeeRate;
BASIS_PRECISION
uint256 constant BASIS_PRECISION = 10_000;
Functions
constructor
constructor(
IProtocolConfig _protocolConfig,
address _manager,
uint256 _withdrawFeeRate
)
Base(_protocolConfig.protocolAdmin(), _protocolConfig.pauser());
onWithdraw
Executes the withdrawal process, returning the amount of shares to burn and fees.
The sender and owner parameters are not used in this implementation.
function onWithdraw(
address,
uint256 assets,
address receiver,
address
)
external
returns (uint256 shares, uint256 fees);
Parameters
Name | Type | Description |
---|---|---|
<none> | address | |
assets | uint256 | The amount of assets to withdraw. |
receiver | address | The address that will receive the assets. |
<none> | address |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares to burn. |
fees | uint256 | The amount of fees to be paid. |
onRedeem
function onRedeem(
address sender,
uint256 shares,
address receiver,
address owner
)
external
returns (uint256 assets, uint256 fees);
maxWithdraw
A user cannot withdraw in the live status.
function maxWithdraw(address owner) external view returns (uint256 assets);
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The max amount of assets that the user can withdraw. |
maxRedeem
A user cannot redeem in the live status.
function maxRedeem(address owner) external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | shares The max amount of shares that the user can burn to withdraw assets. |
previewWithdraw
Preview the amount of shares to burn to withdraw the given amount of assets.
It always rounds up the result. e.g. 3/4 -> 1.
function previewWithdraw(uint256 assets) public view returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets to withdraw. |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares to burn. |
previewRedeem
Preview the amount of assets to receive after burning the given amount of shares.
function previewRedeem(uint256 shares) external view returns (uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares to burn. |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets to receive. |
setWithdrawFeeRate
function setWithdrawFeeRate(uint256 _withdrawFeeRate) external;
_checkStatusToWithdraw
1. SeniorClosed: Tranches except for equity are allowed. 2. EquityClosed: All tranches are allowed.
function _checkStatusToWithdraw(Status status, uint256 waterfallIndex) internal view returns (bool);
_calculateWithdrawFee
function _calculateWithdrawFee(uint256 assets) internal view returns (uint256);