TrueFi Docs
  • What is TrueFi?
  • 🔎User Guide
    • Lend
      • How to lend
      • How to withdraw
      • Onboarding / KYC (for permissioned pools)
    • Borrow
      • Receiving a loan
      • Repaying a loan
    • Manage
      • Onboarding for managers
      • Creating a vault
      • Disbursing loans
      • Managing KYC/KYB requirements
  • âš¡TrueFi Protocol
    • Lines of Credit
      • Line of Credit tutorial
      • Lines of Credit technical details
    • Asset Vaults
      • Asset Vault tutorial
      • Asset Vault technical details
    • Credit Vaults
      • Credit Vault tutorial
      • Credit Vault technical details
        • Credit Vault contract overview
        • Waterfall details
    • Index Vaults
      • Index Vault tutorial
      • Index Vault technical details
    • TRU token
      • Staked TRU
      • How to Get TRU
    • Other concepts
      • Controllers
      • Instruments
        • FixedInterestOnlyLoan
        • BulletLoans
      • [Legacy] DAO pools
        • delt.ai loan: Jan 2023 airdrop claiming instructions
        • delt.ai loan: July 2023 airdrop claiming instructions
        • delt.ai loan: October 2023 airdrop claiming instructions
        • delt.ai loan: Jan 2024 airdrop claiming instructions
        • delt.ai loan: Apr 2024 airdrop claiming instructions
        • delt.ai loan: Nov 2024 airdrop claiming instructions
        • Loan approval process
        • Lender FAQs
          • Lending to DAO pools
          • Farming TRU rewards
          • Withdrawing funds
          • How lending pool (LP) tokens work
          • How loan tokens work
          • SAFU (Secure Asset Fund for Users)
          • Risk Mitigation
        • Developer docs
      • Other legacy contracts
        • Managed Portfolio [legacy]
        • Flexible Portfolios [legacy]
          • Flexible Portfolio contracts
    • Audits
Powered by GitBook

General

  • TrueFi app
  • Docs

Governance

  • Tally
  • Snapshot

Community

  • Forum
  • Twitter
On this page
  • Valuation
  • Fees
  • Deposit / Withdrawal Strategies
  • FlexiblePortfolioFactory

Was this helpful?

Export as PDF
  1. TrueFi Protocol
  2. Other concepts
  3. Other legacy contracts
  4. Flexible Portfolios [legacy]

Flexible Portfolio contracts

PreviousFlexible Portfolios [legacy]NextAudits

Last updated 1 year ago

Was this helpful?

FlexiblePortfolio is a contract that serves as a portfolio of funds managed by the portfolio manager.

FlexiblePortfolio allows the portfolio manager to define allowed debt instruments that the portfolio will handle. This is the latest iteration of the previous portfolio contract version (called ManagedPortfolio).

Contract Name
Address

FlexiblePortfolio

FlexiblePortfolioFactory

FlexiblePortfolio supports loans that yield both principal and interest amounts on repayments. That is, the principal amount goes straight to portfolio liquid funds and can be withdrawn/lent at any moment. Interest is split between all lenders proportionally to the amount of portfolio tokens they hold. This implies that if the tokens are held in a contract (e.g. Uniswap pool), the interest will be frozen in the portfolio.

Valuation

FlexiblePortfolio valuation is handled by the ValuationStrategy, which is a contract that holds information on all the loans the portfolio holds and can evaluate them properly. This requires the portfolio to call onInstrumentFunded when a loan is funded and onInstrumentUpdated when a loan might change its status (e.g. is repaid or gets defaulted). Valuation strategies cannot be switched as they hold the state of the portfolio loans.

Fees

Whenever an action that changes FlexiblePortfolio value is performed (fundInstrument/repay/deposit/mint/withdraw/redeem/updateAndPayFee), a fee for the TrueFi DAO is calculated and immediately transferred to the TrueFi DAO Treasury address. The fee is deducted from the FlexiblePortfolio value, so actions like borrow/withdraw/redeem cannot move the funds that are designated as fees. If the accrued fee cannot be repaid at the moment because of the lack of liquidity, additional information about the fee amount is stored in the contract and will be used to make the overdue payment the moment it will be possible. The same behavior is followed by the fee of the manager.

The protocolAccruedFee value is equal to:

(current_timestamp - last_update_timestamp) / YEAR * protocol_fee_rate * portfolio_value

The managerAccruedFee value is equal to:

(current_timestamp - last_update_timestamp) / YEAR * manager_fee_rate * portfolio_value

**protocol_fee_rate is the rate taken from the Protocol Config contract the last time an update was made. The same goes for manager_fee_rate, which is taken from Fee Strategy

Deposit / Withdrawal Strategies

Functions enabling Lenders to deposit/withdraw funds to/from the contract can additionally be limited by Deposit/Withdraw Strategy. These strategies (if set), are called with a hook every time a specific action is performed on the contract. The same calldata as for the initial call is passed to them, and then the strategy independently decides if this action can or cannot be performed. The strategies might also write some state to themselves on such hooks, but this is not a mandatory behavior. Additionally, these hooks can return a fee that would be applied for the action that is being performed. The fees are calculated independently by the strategy and have to be returned as absolute values and always in assets(not shares).

Here we present a few examples to better understand this process:

  • deposit(assets: 100) is being called, the strategy onDeposit() returns (true, fee: 10). This means that 10 would be transferred to the manager, and the shares would be minted to the Lender based on the remaining 90.

  • mint(shares: 100) is being called, the strategy onMint() returns (true, fee: 10)

Let’s assume shares:assets are 1:1. 100 has to be transferred to the portfolio and 10 to the manager to satisfy the fee and the Lender’s desire to have 100 shares minted. We calculate the fees for withdraw/redeem the same way.

FlexiblePortfolioFactory

This contract serves for deploying a new Flexible Portfolio. All of the FlexiblePortfolio parameters are chosen by the portfolio manager, except for ProtocolConfig.

FlexiblePortfolio satisfies requirements, meaning it meets all features described .

âš¡
ERC-4626
here
0x5c6b0d8070ddc0a6a85c460819c3a91c628070ec
0x122d3ba54975bdeb7579938fb0ffc54f8baefd2a
LogoGitHub - trusttoken/contracts-helium: TrueFi smart contracts second release 2022.GitHub