ManagedPortfolio contract
contracts-ragnarok/ManagedPortfolio.sol at main · trusttoken/contracts-ragnarok
GitHub
ManagedPortfolio represents a portfolio of BulletLoans. Lenders put funds into the portfolio, the manager uses funds to issue loans to borrowers, and borrowers repay principal and interest back into the portfolio. ManagedPortfolio issues ERC-20 Liquidity Provider tokens to lenders in proportion to the amount they lend. These tokens represent a lender's share of the funds in the pool, including the interest accumulated from loans repaid by borrowers.
All of the portfolio operations are up to the manager's discretion. The Portfolio Manager makes decisions about issuing new loans, marking them as defaulted, altering portfolio params and so on. Manager also specifies an ILenderVerifier contract that is responsible for handling the permissions to join the portfolio (portfolios might be permissionless, but typically are not and only offer entrance to a defined group of lenders).
Portfolio tokens represent lenders' share in the pooled funds. Lenders put funds into the portfolio if they trust the manager is going to abide by a reasonable policy. Funds from the portfolio are only available for withdrawal after the portfolio's close date.

Methods

deposit(uint256 depositAmount, bytes memory metadata)

Lends a certain amount of underlying tokens to the portfolio. If the portfolio has lender restrictions enabled, this function requires metadata to validate the lender’s address is allowed to lend.

withdraw(uint256 sharesAmount, bytes memory)

After the portfolio’s close date, lender can withdraw funds, i.e. redeeming the portfolio token for underlying pool tokens.

createBulletLoan( uint256 loanDuration, address borrower, uint256 principalAmount, uint256 repaymentAmount )

Creates bullet loan token using BulletLoans contract.

markLoanAsDefaulted(uint256 instrumentId)

Only the portfolio’s manager can mark a loan as defaulted.

markLoanAsResolved(uint256 instrumentId)

Only the portfolio’s manager can mark a loan as resolved. Intended to be used for situations after partial repayment where a loan workout has been agreed to.

setEndDate(uint256 newEndDate)

Manager can change portfolio’s close date, or EndDate. Note that the portfolio’s close date can only be decreased. Close date can NOT be moved further into the future, nor can it be decreased to a date earlier than any active loan’s maturity date.

setLenderVerifier(ILenderVerifier _lenderVerifier)

​Manager can set the lender verifier contract to enforce lender restrictions. Manager can leverage three different types of restrictions:
  • Whitelist: contract that implements simple, universal whitelist.
  • WhitelistLenderVerifier: contract that implements a unique whitelist for each of the portfolios, which are using this verifier. Managers of particular portfolios have the authority to manage respective whitelists.
  • SignatureOnlyLenderVerifier: contract that requires the lender to provide a signature of a predefined message.

setManagerFee(uint256 _managerFee)

Manager can set the portfolio fee, or managerFee, in basis points. Portfolio fee is charged on deployed capital

setMaxSize(uint256 _maxSize)

Manager sets a cap, or maxSize, for a portfolio. Lenders can not put more funds into the portfolio if it would cause the total principal amount lent into the portfolio to exceed the maxSize.

updateLoanParameters( uint256 instrumentId, uint256 newTotalDebt, uint256 newRepaymentDate )

Manager can modify loan terms, changing maturity date or total debt to be repaid. In order to change the maturity date to an earlier date or increase the repayment value, the borrower must consent and provide a signature.
View Methods

getStatus()

Returns status of the portfolio. If current date is past the portfolio’s close date, will return ‘Closed’. If portfolio holds defaulted loans, will return ‘Frozen’.

getAmountToMint(uint256 amount)

Returns the amount of portfolio tokens that would be minted for a given amount of tokens to be lent (e.g. if 1000 USDC are lent, 995 tfExamplePortfolio tokens would be minted).

getOpenLoanIds()

Returns list of open loan tokens.

illiquidValue()

Returns estimated value of active, illiquid loans. Calculated on straight-line basis.

liquidValue()

Returns balance of idle underlying tokens held by portfolio.

value()

Returns total estimated value of portfolio (liquidValue + illiquidValue).
Export as PDF
Copy link
Outline
Methods​