TranchePool
Inherits: ITranchePool, UpgradeableBase, ERC20Upgradeable, TokenBalanceTrackerUpgradeable
This smart contract represents a tranche pool in a portfolio of loans managed by tranches. Each tranche pool can have different risk profiles and yields within the portfolio. The main functions of this contract include setting the associated portfolio, deposit and withdraw controllers, ceiling for each tranche pool, and converting between assets and shares. It works in conjunction with the Portfolio contract and relies on external controllers for deposit and withdrawal management. This contract also implements the IERC4626 standard.
State Variables
portfolio
the associated portfolio for this tranche pool
IPortfolio public portfolio;
depositController
IDepositController public depositController;
withdrawController
IWithdrawController public withdrawController;
token
ERC20 token to deposit
IERC20 public token;
feeReceiver
address public feeReceiver;
ceiling
the ceiling for this tranche pool
uint256 public ceiling;
waterfallIndex
the waterfall index for this tranche pool. 0 is equity and 1 is senior
uint256 public waterfallIndex;
Functions
initialize
Use portfolio.paused() for pausable
function initialize(
string memory _name,
string memory _symbol,
IProtocolConfig _protocolConfig,
IDepositController _depositController,
IWithdrawController _withdrawController,
IERC20 _token,
address manager,
uint256 _ceiling,
uint256 _waterfallIndex
)
public
initializer;
portfolioNotPaused
modifier portfolioNotPaused();
asset
function asset() external view returns (address assetTokenAddress);
totalAssets
function totalAssets() public view returns (uint256 totalManagedAssets);
availableLiquidity
function availableLiquidity() public view returns (uint256);
deposit
function deposit(uint256 assets, address receiver) external portfolioNotPaused returns (uint256);
convertToShares
function convertToShares(uint256 assets) external view returns (uint256 shares);
convertToSharesCeil
Converts a given amount of assets to shares (rounded up)
function convertToSharesCeil(uint256 assets) external view returns (uint256 shares);
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | The amount of assets to convert |
Returns
Name | Type | Description |
---|---|---|
shares | uint256 | The equivalent amount of shares |
convertToAssets
function convertToAssets(uint256 shares) external view returns (uint256 assets);
convertToAssetsCeil
Converts a given amount of shares to assets (rounded up)
function convertToAssetsCeil(uint256 shares) external view returns (uint256 assets);
Parameters
Name | Type | Description |
---|---|---|
shares | uint256 | The amount of shares to convert |
Returns
Name | Type | Description |
---|---|---|
assets | uint256 | The equivalent amount of assets |
maxDeposit
function maxDeposit(address receiver) public view returns (uint256 maxAssets);
previewDeposit
function previewDeposit(uint256 assets) external view returns (uint256 shares);
maxMint
function maxMint(address receiver) public view returns (uint256 maxShares);
previewMint
function previewMint(uint256 shares) external view returns (uint256 assets);
mint
function mint(uint256 shares, address receiver) external portfolioNotPaused returns (uint256);
maxWithdraw
function maxWithdraw(address owner) public view returns (uint256 maxAssets);
previewWithdraw
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
withdraw
function withdraw(uint256 assets, address receiver, address owner) external portfolioNotPaused returns (uint256);
maxRedeem
function maxRedeem(address owner) public view returns (uint256 maxShares);
previewRedeem
function previewRedeem(uint256 shares) external view returns (uint256 assets);
redeem
function redeem(uint256 shares, address receiver, address owner) external portfolioNotPaused returns (uint256);
setDepositController
Sets the deposit controller for this tranche pool
function setDepositController(IDepositController newController) external;
Parameters
Name | Type | Description |
---|---|---|
newController | IDepositController | The new deposit controller to set |
setWithdrawController
Sets the withdraw controller for this tranche pool
function setWithdrawController(IWithdrawController newController) external;
Parameters
Name | Type | Description |
---|---|---|
newController | IWithdrawController | The new withdraw controller to set |
setCeiling
Sets the ceiling for this tranche pool
function setCeiling(uint256 newCeiling) external;
Parameters
Name | Type | Description |
---|---|---|
newCeiling | uint256 | The new ceiling to set |
setPortfolio
Sets the portfolio for this tranche pool
function setPortfolio(IPortfolio _portfolio) external;
Parameters
Name | Type | Description |
---|---|---|
_portfolio | IPortfolio | The new portfolio to set |
onPortfolioStart
Called when the portfolio starts
function onPortfolioStart() external returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The balance of the tranche pool |
increaseTokenBalance
Increases the token balance of the tranche pool by the given amount
function increaseTokenBalance(uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount to increase the token balance by |
_payDepositFee
function _payDepositFee(uint256 fee) internal;
_payWithdrawFee
function _payWithdrawFee(uint256 fee) internal;
_transferAsset
function _transferAsset(address to, uint256 amount) internal;
_transferAssetFrom
function _transferAssetFrom(address from, address to, uint256 amount) internal;
_depositAssets
function _depositAssets(uint256 assets, uint256 shares, address receiver) internal;
_withdrawAssets
function _withdrawAssets(uint256 assets, uint256 shares, address receiver, address owner) internal;
_safeBurn
function _safeBurn(address owner, uint256 shares) internal;
_requirePortfolio
function _requirePortfolio() internal view;