All pages
Powered by GitBook
1 of 26

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Other concepts

TrueFi infrastructure enables lenders, borrowers, and portfolio managers to deploy capital via lending pools and loans.

Portfolio managers on TrueFi deploy lending pools (or vaults) which in turn can deploy capital to borrowers via loans (instruments).

The following smart contracts represent vaults and instruments within the TrueFi protocol:

Credit Vault contract overviewFlexible Portfolio contractsLines of Credit technical details
FixedInterestOnlyLoanBulletLoans

Audits & Security

View audits .

ManagedPortfolioFactory
ProtocolConfig
here

Instruments

Instruments are representations of loans and other financial instruments. The initial two instruments on TrueFi are:

FixedInterestOnlyLoan

BulletLoans (deprecated)

Other legacy contracts

Controllers

🚀 Intro

Controllers regulate different aspects of how TrueFi products work.

They are responsible for key decision-making on how to perform most of the lender-facing operations. There are three Controllers that TrueFi utilizes:

  • Transfer Controller

  • Deposit Controller

  • Withdrawal Controller

They can implement any logic and freely interact with any external on-chain or off-chain systems.

The details of how these controller work, what are they exactly responsible for and how Vaults interact with them is located below.

How to read interface notation

whenThisFunctionIsCalledOnTheVault(arguments)

vaultCallsThisFunctionOnTheController(msg.sender, arguments)

Returns:

  • controllersResponse - description of how the Vault will handle the Controller’s response

Parameters of the Vault’s methods are described in the .


🔁 Transfer Controller

Transfer Controller is responsible for setting restrictions around transfers of the share token (LP token). Transfer controller has to be capable of making a binary decision whether a particular transfer is allowed or not.

Interface

transfer(to, value)

transferFrom(from, to, value)

onTransfer(msg.sender, from, to, value)

Returns:

isTransferAllowed - boolean determining whether a particular transfer is allowed or not (vault will execute the transfer on true and block the revert the transfer on false)

Examples

Examples of the most common Transfer Controllers are:

  • open - all transfers are allowed

  • blocked - all transfers are forbidden and only minting or burning the token is allowed

  • restricted - only transfers to farming contract (the one distributing incentives) are allowed


⤵️ Deposit Controller

Deposit Controller is responsible for handling all deposits. On a high level it can set:

  • Lender restrictions (who can deposit into the Vault and when)

  • LP token price at the deposit

  • Deposit fee paid to the Portfolio Manager

  • Maximum amount that can be deposited

Interface

deposit(assets, receiver)

onDeposit(msg.sender, assets, receiver)

Returns:

  • shares - how many shares are gonna be minted to the receiver

  • depositFee - how much is going to be subtracted from assets and sent to the manager beneficiary address

mint(shares, receiver)

onMint(msg.sender, shares, receiver)

Returns:

  • assets - how many assets are going to be sent from receiver to the portfolio

  • mintFee - how many assets are going to be sent from receiver to the manager fee beneficiary

Additionally, Deposit Controller needs to handle all the necessary view functions. The Vault calls these functions on the Controller, when they are called on the Vault. Their interfaces are identical to the original ERC-4626 interfaces.

  • previewDeposit(assets) - returns how many LP will the depositor get for the assets

  • maxDeposit(receiver) - returns max amount of assets that can be put into deposit (before fee subtraction)

  • previewMint(shares) - returns how many assets does user need to send to mint particular number of shares (actually deposited + fee)

Examples

Examples of the most common Deposit Controllers are:

  • Simple - deposits are always allowed, setting deposit ceiling

  • Simple with lender restrictions - deposits are allowed for KYCed users, setting deposit ceiling

  • Almighty - Portfolio Manager can set custom deposit parameters for each user (LP token price, fee, deposit limit)


⤴️ Withdrawal Controller

Withdrawal Controller is responsible for handling all withdrawals. It can set:

  • Who and when can withdraw the Vault

  • LP token price at the withdrawal

  • Withdrawal fee paid to the Portfolio Manager

  • Maximum amount that can be withdrawn

Interface

withdraw(assets, receiver, owner)

onWithdraw(msg.sender, assets, receiver, owner)

Returns:

  • shares - how many shares are gonna be burned from the owner

  • withdrawFee - how much is going to be withdrawn from the vault on top of the assets and sent to the manager beneficiary address

**redeem(shares, receiver, owner)**

onRedeem(msg.sender, shares, receiver, owner)

Returns:

  • assets - how many assets are going to be sent from the vault to the receiver

  • mintFee - how many assets are going to be taken from the vault on top of the assets and sent to the manager fee beneficiary

Additionally, Withdrawal Controller handles necessary view functions. Their interfaces are identical to the original ERC-4626 interfaces.

  • previewWithdraw(assets) - returns how many LP will one need to burn in order to get desired amount of assets

  • maxWithdraw(owner) - returns max amount of assets that can be withdrawn (after paying fee)

  • previewRedeem(shares) - returns how many assets will user get (after paying fee) for a particular redeem

Examples

Examples of the most common Withdrawal Controllers are:

  • Simple - withdrawals are always allowed, setting withdrawal floor

  • Almighty - Portfolio Manager can set custom withdrawal parameters for each user (LP token price, fee, deposit limit)


💡 General Guidelines

👮‍♂️ Controller Whitelist

Controllers are approved by DAO Governance. Only approved Controllers are available in the TrueFi interface. Any new Controller proposal should consist not only of smart contract, but also a json file that would configure the controller UI in Portfolio Manager settings, a UI of actions on redeem / deposit button and so on.

Controller Whitelisting Request

A Controller Whitelisting Request should include

  • All on-chain addresses necessary to properly integrate the Controller

  • Controller source code

  • UI JSON file

    • List of fields and options for controller column in the UI

🌗 Portfolio Phases Support

It’s important for Deposit and Withdrawal Controllers to support Portfolio lifecycle phases. Behavior of the Controller should match the intentions expressed in the documentation of a particular TrueFi product, that the Controller is aiming to serve.

Examples:

  • A good and predictable Withdrawal Controller would remove all restrictions for withdrawing when the Portfolio goes into Closed state.

  • A good and predictable Deposit Controller would ban all deposits when the Portfolio goes into Closed state

🗂 State Management

Controllers typically don’t hold any state, so their deployment doesn’t require a separate proxy contract for storage. The easiest and the fastest way to onboard a controller is the one that doesn’t hold any vault-specific state. It can store a general state and delegate decisions to other, state-holding contracts. Generally, Controllers are free to delegate any logic to other, external contracts.

The process of deploying state-holding controllers is a more complicated, as it requires the deployment of a proxy, but it is still possible and if there is a need to do so, builders are welcome and encouraged to do so.

Lender restrictions

Lender restrictions could be built within the Controller, but it’s more common for logic on lender restricitions to be delegated outside of the Controller.

A Controller can utilize another contract to check whether a user is allowed to interact with the Vault by checking an allowlist, NFT ownership, SBT ownership, etc.

[Legacy] DAO pools

[Legacy] Lending pools governed by TRU stakers

For developer docs see

TrueFi DAO-managed lending pools (tfUSDC, tfUSDT, tfTUSD, tfBUSD) lend to institutional crypto borrowers that request loans from the protocol. Loans must be and meet risk / return criteria set by the protocol.

For Lenders

FixedInterestOnlyLoan

FixedInterestOnlyLoans is an ERC-721 contract. Each minted NFT represents a loan that must be paid back to the NFT owner.

Loan Parameters

Each loan is parametrized by:

  • Underlying token with which funds are lent out and repaid (e.g. USDC)

Withdrawing funds

Liquid Exit and other FAQs

How can I exit the lending pools?

You can exit the pool by selling your lending pool tokens to the TrueFi lending pools for the stablecoin if there is enough liquid asset in the pool to support the transaction. This feature is also called liquid exit.

Risk Mitigation

Has TrueFi been audited?

Yes, please see TrueFi's technical audits .

How does TrueFi mitigate risk?

Potentially many more via implicit manipulation of the response parameters…

maxMint(receiver) - returns max amount of shares that can be minted

Potentially many more via implicit manipulation of the response parameters…

maxRedeem(receiver) - returns max amount of shares that can be burned to redeem

  • Actions to execute upon click on Lender’s UI elements

  • ERC-4626 documentation

    Start here to learn how TrueFi DAO pools work.

    For Borrowers

    Learn how to borrow from TrueFi DAO pools here:

    TrueFi DAO pool loan lists are available at
    Developer docs
    approved by the protocol
  • Principal debt (minting price)

  • Period payment (interest paid at each installment)

  • Period length (a period when the borrower pays installments)

  • Period count (total number of installments)

  • End date (date of the last installment to be paid together with the principal, set when the loan is started)

  • Recipient’s address

  • Grace period (time by which borrower can be late in repayment of each installment)

  • A canBeRepaidAfterDefault flag that allows a loan to be repaid after a loan was marked as defaulted

  • Loan states & state transitions

    A loan can have one of the possible statuses: Created, Accepted, Started, Repaid, Canceled, or Defaulted.

    Upon minting the loan status is set to Created. In this state, a borrower can accept a loan by calling acceptLoan(id) and the loan status is changed to Accepted.

    The NFT owner can call start(id) on loans whose status is Accepted. When a loan is started the loan end date is calculated for the loan and the loan status is changed to Started.

    The NFT owner can mark loans as canceled whose status is Created or Accepted.

    The NFT owner can mark loans as Defaulted whose status is Started and the current block time is after a current period endDate + gracePeriod time.

    The NFT owner can update the loan's gracePeriod at any time by calling updateInstrument(id). The NFT owner must call repay(id, amount) to recalculate repaid periods and the current period end date.

    The repaid amount must be equal to the period payment or period payment + principal for the last installment. The loan can be repaid after it was marked as defaulted only if the proper canBeRepaidAfterDefault flag was set to true.

    What is Liquid Exit?

    ‌Liquid exit addresses a key community request which is the ability to exit the TrueFi Lending Pool directly into the underlying stablecoin. Lending pool token holders can redeem their LP tokens for the stablecoin for an exit fee.

    The exit fee is inversely proportional to the amount of available idle liquidity in the pool. For example, when there is a large amount of liquid assets in the pool, the fee is low. When there is a small amount of liquid asset in the pool, the fee is high. This fee is earned by the pool for the existing lending pool token holders.

    The exit fee charged to you for an exit would be made available to you in the UI. If you feel that the fee charged is too high then you can wait till the pool is more liquid and try again later.

    1) If there is no liquid asset in the lending pool and no liquid exit is deployed in Curve.

    2) If the pool needs to liquidate its position in Curve and will incur a loss of more than 10 basis points.

    Click here to view the relationship between Pool utilization and exit fees.

    TrueFi takes multiple measures to help protect lenders:
    • Staked TRU provides default protection for lenders and governs the loan approval process

    • Borrowers on TrueFi follow a thorough Know Your Business (“KYB”) workflow and credit review which incorporates both on-chain and off-chain data, such as company background, repayment history, operating & trading history, assets under management, and credit metrics.

    • TrueFi handles bad debt via a Secure Asset Fund for Users (“SAFU”) smart contract.

    • TrueFi lenders can also purchase through Nexus Mutual to hedge risks when lending on TrueFi. Coverage is paid out at the discretion of mutual members but has covered technical exploits in the past.

    This is not investment advice. Please Do Your Own Research.

    here

    delt.ai loan: Nov 2024 airdrop claiming instructions

    Airdrop claiming instructions, provided by Archblock

    Summary

    The airdrop comes in the form of an ERC4626 tokenized vault (0x4ed292bc0A5A411c6BFE436a3617835B94077F44), with mints and deposits disabled. This contract has undergone an internal security review and an external audit by ChainSecurity.

    Shares of the airdrop are proportional to token holders of the tfUSDC lending pool as of January 9, 2023, the original end date of the delt.ai loan. This includes lenders who farmed their tfUSDC holdings, as well as claimable tfUSDC rewards from the stkTRU contract.

    In order to prevent locked funds in the contract, you will have until a deadline of May 22, 2025 to redeem your shares of the interest airdrop.

    After this date, TrueTrading will recover the remainder of funds.

    NOTE: You may want to wait until gas prices are low before calling the redeem( ) function.

    Step-by-step

    1. Check your balance of shares :

    In this example, the address 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F has a balance of 73,990.677577, which means it can claim 73,990.677577 USDC. There should be six digits after the decimal point.

    1. Connect your wallet to Etherscan on by clicking the “Connect to Web3” button as indicated below:

    1. Click, “Contract” and “Write as Proxy”, then call the redeem() function (#9, 0xba087652):

    For shares, enter your balance from #1 (but drop the decimal point and any commas): 73990677577.

    For both receiver and owner, enter your wallet address from #1: 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F

    1. Review this transaction carefully, click Write, and then confirm via your wallet.

    Support

    Please reach out to us if you have a smart contract with claimable airdrop balance, but no ability to call redeem(). If you can prove ownership of the contract, then we may be able to work out a way for you to receive your share.

    If you have any questions or need assistance, please contact us at .

    BulletLoans

    BulletLoans is in the process of being sunset.

    New TrueFi Capital Markets portfolios deployed after June 2022 use FixedInterestOnlyLoan

    ​​​BulletLoans is an ERC-721 contract. Each of the tokens represents a single loan.

    All loan parameters can be read from LoanMetadata struct. BulletLoans contract enables loan creation, facilitates loan repayment and allows managing the loan's state and parameters.

    Methods

    createLoan( IERC20 _underlyingToken, uint256 _principal, uint256 _totalDebt, uint256 _duration, address _recipient )

    Manager can create loan by passing the principal to be lent, the total debt to repaid, duration of the loan, and the address of the recipient. Total debt to be repaid cannot be less than principal amount. ​

    repay(uint256 instrumentId, uint256 amount)

    Existing loan can be repaid partially or in full. If loan is paid in full, this function will mark the loan’s status to ‘Fully Repaid’. Note that a loan cannot be overpaid.

    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.

    updateLoanParameters( uint256 instrumentId, uint256 newTotalDebt, uint256 newRepaymentDate )

    Manager can modify loan terms, changing maturity date or total debt to be repaid.

    updateLoanParameters( uint256 instrumentId, uint256 newTotalDebt, uint256 newRepaymentDate, bytes memory borrowerSignature )

    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

    principal(uint256 instrumentId)

    Returns principal amount of loan.

    underlyingToken(uint256 instrumentId)

    Returns underlying token (e.g. USDC, USDT) of the loan.

    recipient(uint256 instrumentId)

    Returns borrower’s address.

    endDate(uint256 instrumentId)

    Returns maturity date of the loan.

    unpaidDebt(uint256 instrumentId)

    Returns remaining amount to be paid, i.e. total debt less repaid amount.

    getStatus(uint256 instrumentId)

    Returns status of loan (Issued, FullyRepaid, Defaulted, Resolved).

    SAFU (Secure Asset Fund for Users)

    What is the SAFU?

    The SAFU is an overhaul of how TrueFi handles borrower defaults. The SAFU smart contract is responsible for all bad debt accrued by the protocol. The SAFU has been initially funded by TrustToken and the funds will help cover defaults.

    In case of a loan default, TrueFi lending pools will transfer all bad debt assets to the SAFU in exchange for the full expected value of those assets. Then, the SAFU will slash staked TRU tokens, up to 10% of the defaulted amount. If the value of these slashed tokens is not enough to cover the default, the SAFU will use its funds to help repay the affected lending pool for lost funds.

    SAFU default handling

    In the event of a default, the following occurs:

    1. Up to 10% of TRU is slashed from the staking pool and transferred to the SAFU to cover the defaulted amount, equal to the principal amount plus the full amount of expected interest (“Defaulted Amount”)

    2. All the defaulted LoanTokens will be transferred from the lending pool to the SAFU

    3. If the current SAFU funds are insufficient to cover the defaulted loan; the SAFU can sell TRU for the respective borrowed asset at its manager’s discretion

    Smart Contract Architecture

    The SAFU replaces what was called “Liquidator” in previous TrueFi versions. Therefore, it will have permission to slash TRU from the staked TRU pool.

    The funds in the SAFU will be managed by an approved address, automating as much capital management as possible through DeFi. In the initial version, the funds' management will be somewhat centralized to maximize the capital efficiency when making exchanges between tokens. For example, the price impact of exchanging TRU on decentralized exchanges is much higher than the impact of OTC or centralized exchange opportunities.

    Nevertheless, following the ethos of progressive decentralization, future unlocks will include updates to the SAFU which will further decentralize the management of the SAFU funds.

    delt.ai loan: July 2023 airdrop claiming instructions

    Airdrop claiming instructions, provided by Archblock

    Summary

    The airdrop comes in the form of an ERC4626 tokenized vault (00xfBc33285d9f58d34fE239bFA3732036d5c53a1665), with mints and deposits disabled. This contract has undergone an internal security review and an external audit by ChainSecurity.

    Shares of the airdrop are proportional to token holders of the tfUSDC lending pool as of January 9, 2023, the original end date of the delt.ai loan. This includes lenders who farmed their tfUSDC holdings, as well as claimable tfUSDC rewards from the stkTRU contract.

    In order to prevent locked funds in the contract, users will have until a deadline of January 21, 2024, to redeem your shares of the interest airdrop.

    After this date, TrueTrading will recover the remainder of funds.

    You may want to wait until gas prices are low before calling the redeem( ) function.

    Step-by-step instructions

    1. Check your balance of shares :

    In this example, the address 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F has a balance of 73,990.677577, which means it can claim 73,990.677577 USDC. There should be six digits after the decimal point.

    1. Connect your wallet to Etherscan on by clicking the “Connect to Web3” button as indicated below

    2. Click, “Contract” and “Write as Proxy”, then call the redeem() function (#9, 0xba087652):

    For shares, enter your balance from #1 (but drop the decimal point and any commas): 73990677577 in the example.

    For both receiver and owner, enter your wallet address from #1: 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F in the example

    1. Review this transaction carefully, click Write, and then confirm via your wallet.

    Support

    If you have any questions or need assistance, please contact .

    Please reach out to if you have a smart contract with claimable airdrop balance, but no ability to call redeem(). If you can prove ownership of the contract, they may be able to work out a way for you to receive your share.

    delt.ai loan: Apr 2024 airdrop claiming instructions

    Airdrop claiming instructions, provided by Archblock

    Summary

    The airdrop comes in the form of an ERC4626 tokenized vault (0xCfaC5fDFa94aD0de96979ae9Fb1A5b747588f954), with mints and deposits disabled. This contract has undergone an internal security review and an external audit by ChainSecurity.

    Shares of the airdrop are proportional to token holders of the tfUSDC lending pool as of January 9, 2023, the original end date of the delt.ai loan. This includes lenders who farmed their tfUSDC holdings, as well as claimable tfUSDC rewards from the stkTRU contract.

    In order to prevent locked funds in the contract, you will have until a deadline of October 04, 2024 to redeem your shares of the interest airdrop.

    After this date, TrueTrading will recover the remainder of funds.

    NOTE: You may want to wait until gas prices are low before calling the redeem() function.

    Step-by-step

    1. Check your balance of shares :

    In this example, the address 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F has a balance of 73,990.677577, which means it can claim 73,990.677577 USDC. There should be six digits after the decimal point.

    1. Connect your wallet to Etherscan on by clicking the “Connect to Web3” button as indicated below:

    2. Click, “Contract” and “Write as Proxy”, then call the redeem() function (#9, 0xba087652):

    For shares, enter your balance from #1 (but drop the decimal point and any commas): e.g. 73990677577.

    For both receiver and owner, enter your wallet address from #1: e.g. 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F

    1. Review this transaction carefully, click Write, and then confirm via your wallet.

    Support

    If you have any questions or need assistance, please contact .

    Please reach out to if you have a smart contract with claimable airdrop balance, but no ability to call redeem(). If you can prove ownership of the contract, they may be able to work out a way for you to receive your share.

    How loan tokens work

    What are loan tokens?

    Loan tokens are non-tradable ERC-20 tokens which represent the lender’s proportional representation in a loan that is issued from the Lending Pool.

    Each loan issued from the Lending Pool will create a unique loan token used to track the present value of each loan. Loan tokens form an important building block of TrueFi, as they can operate independently from the TrueFi lending pools. Tokenized loans open up opportunities for calculating and tracking the value to the individual loans within the Lending Pool. TrueFi does not allow for the transfer of Loan tokens and will not create a secondary market for loan tokens. It is important to note that all Loan tokens are unique and can be tracked on the Loans page of the TrueFi website.

    Creating a Loan token requires a borrower’s wallet address, principal amount, term, and interest rate or APR associated with a loan. When a loan is , loan tokens are minted by funding the loan token contract with the principal amount. The minted loan tokens represent a share in the total amount payable at the end of the term which is the sum of principal and interest.

    Loan tokens are minted at a discounted rate, meaning that loan tokens paid back in full will converge to a price of 1.000:

    # of loan tokens minted = principal + interest owed at loan maturity

    Once a loan is funded, the borrower can call a function which allows them to borrow the funds from the smart contract. At the end of the term, once the borrower pays back the loan, loan token holders can exchange their loan tokens for an equivalent number of stablecoins.

    Example:

    When a loan with principal = 1,000,000 USDC, term = 30 days, APR = 12% is approved, 1,009,863.013 ( = 1,000,000 + 1,000,000 x 12% x 30/365) loan tokens are minted.

    At maturity, if the borrower repays the entire loan amount along with interest, the lending pool can exchange 1 loan token for 1 USDC.

    What is the value of a loan token at any point of time?

    The theoretical present value of a loan token is calculated by assuming the loan is repaid in full by the end of the loan term.

    The following formulas walk through how lending pools value loan tokens (where loan token `0xabc` represents a single loan, and `t` represents time since loan origination):

    Value of all 0xabc loan tokens minted = principal + (t / term ) x interest

    Value of a single 0xabc loan token = (Value of all 0xabc loan tokens) / (supply of 0xabc loan tokens)

    Value of a single 0xabc loan token = (principal + (t / term ) x interest)/(principal + interest)

    Example:

    When a loan with principal = 1,000,000 USDC, term = 30 days, APR = 12% is approved, 1,009,863.013 ( = 1,000,000 + 1,000,000 x 12% x 30/365) loan tokens are minted.

    The value of a single loan token at n days (where n is less than or equal to 30) is 1,009,863.013 USDC

    Lender FAQs

    How does TrueFi generate yield?

    TrueFi lending pools fund loans to borrowers who request loans from the protocol. Loans must be and meet risk / return criteria set by the protocol. Uncollateralized lending has a higher risk profile than other markets and thus should provide higher returns.

    Lending to DAO pools

    How do I lend?

    Users can lend to TrueFi DAO pools at .

    Once a user is ready to lend, the user will need to complete two transactions:

    1) approve(): User must approve the lending pool smart contract to transfer up to a certain allowance of the asset. Read more .

    How lending pool (LP) tokens work

    After , a lender receives lending pool tokens ("LP tokens"). Read further to find how users can track the value of their LP tokens and trade LP tokens.

    What are Lending Pool tokens ("LP tokens")?

    Lending Pool tokens (or "LP tokens") are tradable ERC-20 tokens that represent a lender’s proportional representation in the pool.

    In the beginning, when no loans have been disbursed by the TrueFi lending pool, lenders will receive one TrueFi Lending Pool Token (tfTUSD, tfUSDC, tfUSDT, or tfBUSD) for every stablecoin lent to the pool.

    As the pool starts earning yields and disbursing loans, the value of the pool tokens may increase or decrease depending on returns within the pool. The value of the pool represents the present value of all its underlying tokens (stablecoins, loan tokens, and other tokens earned).

    Farming TRU rewards

    In addition to earning yield from loan activity in DAO pools, lenders can also earn additional yield in the form of TRU rewards ("yield farming").

    How do I farm TRU rewards?

    TrueFi DAO Pool lenders begin accruing TRU rewards as soon as their LP tokens have been staked.

    Lenders can stake lending pool tokens in the liquidity gauge via the page, or via the function on the TrueMultiFarm contract.

    Flexible Portfolios [legacy]

    Configurable lending pools governed by 3rd party PMs

    For technical docs, see

    Flexible Portfolios are configurable lending pools run by independent managers on TrueFi infrastructure. have discretion over loan terms, as well as other items such as the pool's maximum size, maturity date, and lender access/restrictions.

    Portfolios can serve real world financing borrowers and use cases, as covered by PYMNTS , as well as crypto-focused borrowers (institutions, DAOs, etc., as covered by Bloomberg ).

    If the value of the SAFU funds can not satisfy the defaulted loan:
    1. The difference between the defaulted loan and the SAFU is calculated (“Uncovered Amount”).

    2. The SAFU will issue ERC-20 tokens representing a claim for the Uncovered Amount (“Deficiency Claim”).

    3. Then, the affected lending pool will receive a Deficiency Claim for the Uncovered Amount, assuming its successful recovery.

    4. The affected lending pool will have a first-priority claim on the funds recouped through arbitration for the Deficiency Claim amount.

  • If a debt is repaid:

    1. The recouped funds will be used to purchase the asset that the Loan Token was originally denominated in, which will be transferred to the LoanToken contract.

    2. The SAFU will burn the Loan Tokens for the underlying value of those tokens (“Recovered Amount”)

    3. The SAFU is going to repurchase the issued Deficiency Claim tokens from the lending pool up to the Recovered Amount.

    4. If there is a remainder of the recovered funds after repurchasing the lending pool’s Deficiency Claim, the SAFU keeps those funds.

  • If any portion of the original loan amount is not repaid after the completion of the legal recovery process; the lending pool’s remaining Deficiency Claim tokens are going to be burned thus reducing the LP token price.

  • smart contract cover
    (=1,000,000 + (n/30) x 9,863.013)
    ).
    approved by the pool

    How do I calculate LP token prices?

    We can calculate LP token price by checking the poolValue() and totalSupply() read functions on the lending pool smart contract:

    LP token price = poolValue() / totalSupply()

    We can use this LP token price to find how many LP tokens a lender will receive in return for lending tokens to the pool.

    Example:

    Bob lends 2,000,000 USDC to the tfUSDC pool.

    Given that tfUSDC poolValue()= 46226887530770 and totalSupply()

    42405680290948 at the time of lending, we calculate tfUSDC LP price = 1.0901.

    Bob will thus receive 2,000,000 / 1.0901 = 1,834,675.99 tfUSDC LP tokens

    Additionally, we can calculate the value of a lender's position at any point in time:

    Lender's position value = (# of LP tokens held) * (LP token price)

    Are LP tokens tradable on secondary markets?

    Yes, LP tokens can be traded on secondary markets. There are existing markets on Uniswap v3 today.

    • tfUSDC/USDC: https://info.uniswap.org/#/pools/0xd7c13ee6699833b6641d3c5a4d842a4548030a82

    • tfUSDT/USDT: https://info.uniswap.org/#/pools/0x5cc644472ed7d3198eeb23353bd9236ca578a895

    Why is there a difference between calculated LP token price and its price on Uniswap?

    LP token prices calculated by the lending pool assume that loans will be repaid successfully within the term, among other assumptions.

    Other market participants may have use different assumptions in their calculation of LP token prices. There are several market factors that may govern the price of lending pool tokens and the TrueFi platform does not have any control over them.

    lending to the pool
    Who can lend to portfolios on TrueFi?

    Portfolio managers define who can lend into each portfolio (i.e. whether portfolios are permissioned or permissionless).

    For permissioned portfolios, lenders can gain access to the portfolio by completing onboarding per the manager's instruction (ex. completing KYC process directed by the portfolio manager).

    How are portfolios managed?

    Portfolio Managers (PMs) make decisions on underwriting loans, managing relationships with borrowers, and configuring portfolios. Lenders are responsible for conducting diligence on PMs and portfolios before lending.

    When can lenders withdraw?

    Lenders can withdraw funds only after the portfolio's maturity date. Funds are locked up in the portfolio until the portfolio’s maturity is reached.

    Can lenders transfer portfolio tokens?

    No, portfolio tokens are non-transferrable by default.

    Managers can enable transfers if desired.

    What are the fees on portfolios?

    Portfolios pay a protocol fee per annum to the TrueFi DAO treasury. Fees accrue block-by-block and are paid upon each smart contract interaction (lend/withdraw/disburse loan/repay loan).

    The example below illustrates how the protocol fee works:

    Protocol Fee example

    Take an example portfolio Verum Fund, which holds 1,000,000 USDC worth of loans and assume protocol fee = 50 bps per annum (0.50%).

    Assuming the value of Verum Fund grows linearly from 1,000,000 USDC to 1,100,000 USDC over the course of 30 days (avg. value of 1,050,000 USDC), the portfolio would pay a protocol fee of 431.51 USDC for this time period:

    Protocol fee = 1,050,000 USDC * 0.50% * (30/365) = 431.51 USDC

    Additionally, PMs can set an optional Portfolio Fee. Portfolio Fees are paid to the PM, and can be configured such that they are accrued linearly over time, or paid as a flat fee at time of deposit and/or withdrawal.

    Flexible Portfolio contracts
    Portfolio Managers ("PMs")
    here
    here
    Portfolio on TrueFi
    https://app.truefi.io/loans
    How does lending on TrueFi work?

    Lenders can lend stablecoins to TrueFi lending pools, which use predefined strategies to lend to creditworthy borrowers. See below for a brief demo:

    TrueFi lending pools are controlled by TrueTrading, an affiliate company of TrustToken, Inc. The TrueFi lending pools only lend to a whitelist of trusted borrowers, and any excess capital that is not actively loaned out may be deployed in a DeFi protocol.

    Lenders who lend to the TrueFi lending pool receive TrueFi lending pool tokens ("LP tokens"), which represent their proportion of lent capital in the TrueFi lending pool.

    Is there a lockup period for lenders?

    No. Lenders can redeem LP tokens any time idle funds are available in the pool. Lenders pay an exit fee in order to withdraw instant liquidity from the pool. This fee is calculated dynamically, depending on what proportion of the pool is idle vs. lent to borrowers.

    Additionally, LP tokens can be traded on secondary markets, such as Uniswap.

    Are there any fees for lending to the Lending Pools?

    There are no fees for lending funds into lending pools. To withdraw funds, lenders may pay an exit fee.

    What are the risks involved in lending to the TrueFi lending pool?

    While borrowers are usually willing to pay higher rates for uncollateralized loans, these higher yields do not come without risks. Compared with collateralized lending, uncollateralized lending has two major risks:

    • Potentially increased risk of loss: Protocols that require collateral are protected by that collateral in case of default. While this allows such platforms to be less selective in approving loans, uncollateralized loans come with a much higher standard of trust that must be met by a borrower. In case of default on an uncollateralized loan, a delinquent borrower will have been assessed for creditworthiness before the loan was made and will face both reputational damage and legal action.

    • Potentially lower liquidity: While instant withdrawals are becoming a norm for new protocols, uncollateralized lending may not offer the same flexibility. Most borrowers for uncollateralized loans are interested in fixed-rate, fixed-term loans for predictable repayment. This means lenders who fund such loans need to be comfortable locking up their assets for the duration of the loan. TrueFi offers an alternative: the ability to withdraw their proportion of the pool tokens which would consist of stablecoins and loan tokens that you hold to maturity. You can redeem the loan tokens for the stablecoin at the end of loan terms.

    You can learn more about how TrueFi mitigates risk here.

    Who is responsible for taking legal actions against delinquent borrowers?

    TrueTrading is currently responsible for pursuing legal recourse if a borrower defaults and may be replaced by another non-profit entity in the future as TrueFi progressively decentralizes.

    How can lending pool token holders farm TRU?

    Lending pool token holders can farm TRU by staking their lending pool tokens (tfTUSD, tfUSDC, tfUSDT, or tfBUSD) on the Farm page.

    approved by the protocol
    2) lend(): User lends funds to the lending pool. In return, the lender receives lending pool tokens ("LP tokens").

    ​

    The lender can optionally stake their LP tokens to farm TRU rewards, which generate additional yield on top of underlying returns in the pool.

    Why do I see two options after I click 'Lend'?

    The TrueFi app helps to find lenders the best price when they lend to the pool.

    Lenders can choose between (i) lending funds directly to the pool and minting LP tokens, or (ii) buying LP tokens on a secondary market (Uniswap).

    In the example shown in the screenshot below, the UI shows that the user may be able to get a better price and incur lower gas costs by going directly to Uniswap to get tfUSDC.

    TrueFi Lending Pool smart contracts

    Pool
    Address

    tfTUSD

    tfUSDC

    tfUSDT

    tfBUSD

    Legacy tfTUSD

    https://app.truefi.io/lend
    here
    How to stake LP tokens via

    How do I check and claim my farm rewards?

    At any given time, a lender can check the # of accrued rewards and claim rewards by visiting https://app.truefi.io/farm.

    Additionally, lenders can find the # of TRU rewards by checking claimable() on the TrueMultiFarm contract below:

    Name
    Contract

    TrueMultiFarm

    Lenders can claim TRU rewards by calling claim() on this contract.

    Additionally, lenders can call exit() to unstake LP tokens and claim rewards within the same transaction.

    How are TRU rewards distributed?

    To find the current emissions rate for a farm, users can divide the totalAmount by duration. Visit the etherscan link to the smart contract, click on Contract, then click on Read as Proxy. You will find the two parameters totalAmount and duration. The duration is in seconds.

    TRU distribution per day = (totalAmount/10^8) / (duration/(24*3600))

    Liquidity Gauge TRU Distributor Smart contract

    Name
    Contract

    LinearTrueDistributor

    Are there additional economic risks involved in farming?

    Farming on TrueFi lending pools involves no additional economic risk beyond risks involved as a lender. Users are inherently exposed to borrower default risk as a lender.

    What is TRU?

    Read more about TRU, TrueFi's governance token here.

    Farm
    stake()
    here
    this page
    [email protected]
    here
    this page
    [email protected]
    [email protected]
    here
    this page
    [email protected]
    [email protected]

    Flexible Portfolio contracts

    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

    FlexiblePortfolio satisfies requirements, meaning it meets all features described .

    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.

    Loan approval process

    Voting on loan applications

    To vote on loan applications, you need stkTRU. To learn more about how to acquire stkTRU please view the section on Staking. Once you have stkTRU you can visit the Stake page and vote on the loan applications listed on the page.

    The stkTRU balance with which you can vote on loan applications is equal to the stkTRU balance held by your wallet when the loan application was created. You will not be able to vote on loan applications with any stkTRU balance acquired after a loan application was created.

    Stakers can either vote YES or NO with stkTRU on a loan application. Voting YES means you are predicting that the loan is not likely to default, and voting NO means you are predicting that the loan is likely to default. Stakers can vote with the entire stkTRU balance of their wallet, including the stkTRU balance delegated to their wallet address.

    Voting on loan applications does not lock stkTRU, stakers can use their stkTRU balance to vote on multiple loan applications.

    What’s the voting period for voting on loan applications?

    There is no specific time period for stkTRU holders to vote on loan applications. After a loan application is live on the TrueFi platform, stkTRU holders can start voting on the loan until the loan application is funded by the lending pool or cancelled by the borrower.

    However, there is a minimum time period that must pass before a loan can be funded by the lending pool. This time period is called the minimum voting period which corresponds to the votingPeriod parameter set in the TrueLender smart contract.

    Visit the etherscan link to the TrueLender (proxy) smart contract, click on Contract, then click on Read as Proxy. You will find the parameter votingPeriod in seconds.

    stkTRU holders can modify or cancel their votes any number of times before the loan has been funded by the lending pool or cancelled by the borrower.

    How are loan applications approved?

    stkTRU holders vote YES or NO on whether to approve a loan request. A loan is approved if it satisfies two conditions.

    1. Minimum # of votes (15 million as of Sept 2022)

    2. Minimum ratio of YES-to-NO votes (at least 80% of votes YES, as of Sept 2022)

    Only whitelisted borrowers can submit their loan applications to the TrueRatingAgencyV2 contract. Whitelisted addresses will return true when queried against allowedSubmitters in the TrueRatingAgencyV2 contract.

    Loans are approved or rejected based on conditions set in three smart contracts: TrueFi lending pool contract (tfUSDC et al), TrueRatingAgencyV2, and TrueLender2.

    Contract
    Address

    Incentive for voting on loan applications

    stkTRU holders receive rewards in the form of TRU tokens for voting on loan requests. The rewards become claimable as soon as the loan is withdrawn by the borrower and the status of the loan becomes active. Rewards are distributed to voters based on their share of the total votes received:

    TRU Reward for voting = (# TRU voted by user / # total TRU votes) * (Total TRU Reward), where

    • Total TRU Reward = (Loan interest * TRU distribution factor * rewardMultiplier)

      • where Loan interest = (loan APR * term in days * principal) /365. Loan APR, term, and principal can be obtained from the respective loan token contract

      • rewardMultiplier can be found from the

    delt.ai loan: Jan 2024 airdrop claiming instructions

    Airdrop claiming instructions, provided by Archblock

    Summary

    The airdrop comes in the form of an ERC4626 tokenized vault (0xaAab06b81dA17A11E4Ada38a9DBa1D090D95253a), with mints and deposits disabled. This contract has undergone an internal security review and an external audit by ChainSecurity.

    Shares of the airdrop are proportional to token holders of the tfUSDC lending pool as of January 9, 2023, the original end date of the delt.ai loan. This includes lenders who farmed their tfUSDC holdings, as well as claimable tfUSDC rewards from the stkTRU contract.

    In order to prevent locked funds in the contract, you will have until a deadline of July 9, 2024 to redeem your shares of the interest airdrop.

    After this date, TrueTrading will recover the remainder of funds.

    You may want to wait until gas prices are low before calling the redeem( ) function.

    Step-by-step

    1. Check your balance of shares :

    In this example, the address 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F has a balance of 73,990.677577, which means it can claim 73,990.677577 USDC. There should be six digits after the decimal point.

    For shares, enter your balance from #1 (but drop the decimal point and any commas): 73990677577 in the example.

    For both receiver and owner, enter your wallet address from #1: 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F in the example.

    1. Connect your wallet to Etherscan on by clicking the “Connect to Web3” button as indicated below:

    2. Click, “Contract” and “Write as Proxy”, then call the redeem() function (#9, 0xba087652):

      For shares, enter your balance from #1 (but drop the decimal point and any commas): 73990677577.

    Support

    If you have any questions or need assistance, please contact .

    Please reach out to if you have a smart contract with claimable airdrop balance, but no ability to call redeem(). If you can prove ownership of the contract, they may be able to work out a way for you to receive your share.

    delt.ai loan: Jan 2023 airdrop claiming instructions

    Airdrop claiming instructions, provided by Archblock

    Summary

    The airdrop comes in the form of an ERC4626 tokenized vault (0x37C5867ef19DbE096dF8E125F33f895234E02875), with mints and deposits disabled. This contract has undergone an internal security review and an external audit by ChainSecurity.

    Shares of the airdrop are proportional to token holders of the tfUSDC lending pool as of January 9, 2023, the original end date of the delt.ai loan. This includes lenders who farmed their tfUSDC holdings, as well as claimable tfUSDC rewards from the stkTRU contract.

    In order to prevent locked funds in the contract, you will have until a deadline of July 8, 2023, to redeem your shares of the interest airdrop.

    After this date, TrueTrading will recover the remainder of funds.

    NOTE: You may want to wait until gas prices are low before calling the redeem() function.

    Step-by-step instructions

    1. Check your balance of shares :

    In this screenshot example above, the address 0x168151 has a balance of 73,990.677577, which means it can claim 73,990.677577 USDC. There should be six digits after the decimal point.

    1. Connect your wallet to Etherscan on by clicking the “Connect to Web3” button as indicated below:

    1. Click, “Contract” and “Write as Proxy”, then call the redeem() function (#9, 0xba087652):

      • For both receiver and owner, enter your wallet address from #1: 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F

      • For shares, enter your balance found in step #1, but using 6 decimals

    1. Review this transaction carefully, click Write, and then confirm via your wallet.

    Support

    Please reach out to if you have a smart contract with claimable airdrop balance, but no ability to call redeem(). If you can prove ownership of the contract, then Archblock may be able to work out a way for you to receive your share.

    If you have any questions or need assistance, please contact .

    0x97cE06c3e3D027715b2d6C22e67D5096000072E5
    0xA991356d261fbaF194463aF6DF8f0464F8f1c742
    0x6002b1dcB26E7B1AA797A17551C6F487923299d7
    0x1Ed460D149D48FA7d91703bf4890F97220C09437
    0xa1e72267084192db7387c8cc1328fade470e4149
    0xec6c3FD795D6e6f202825Ddb56E01b3c128b0b10
    0xc7AB606e551bebD69f7611CdA1Fc473f8E5b8f70
    https://app.truefi.io/farm
    contract
  • TRU distribution factor is calculated as remaining divided by amount from the RatingAgencyV2Distributor contract

  • TrueLender2

    0xa606dd423dF7dFb65Efe14ab66f5fDEBf62FF583

    TrueRatingAgencyV2

    0x05461334340568075bE35438b221A3a0D261Fb6b

    TrueRatingAgencyV2
    For both receiver and owner, enter your wallet address from #1: 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F
  • Review this transaction carefully, click Write, and then confirm via your wallet.

  • here
    this page
    [email protected]
    [email protected]

    Following the example from #1, the shares would be 73990677577

  • Note: This number should contain no decimal point and no commas. There should be six digits after the decimal point from #1.

  • here
    this page
    [email protected]
    [email protected]

    FlexiblePortfolioFactory

    0x122d3ba54975bdeb7579938fb0ffc54f8baefd2a

    ERC-4626
    here
    0x5c6b0d8070ddc0a6a85c460819c3a91c628070ec
    GitHub - TrueFi-Protocol/contracts-helium: TrueFi smart contracts second release 2022.GitHub

    delt.ai loan: October 2023 airdrop claiming instructions

    Airdrop claiming instructions, provided by Archblock

    Summary

    The airdrop comes in the form of an ERC4626 tokenized vault (), with mints and deposits disabled. This contract has undergone an internal security review and an .

    Shares of the airdrop are proportional to token holders of the tfUSDC lending pool as of January 9, 2023, the original end date of the delt.ai loan. This includes lenders who farmed their tfUSDC holdings, as well as claimable tfUSDC rewards from the stkTRU contract.

    In order to prevent locked funds in the contract, you will have until a deadline of April 10, 2024, to redeem your shares of the interest airdrop.

    GitHub - TrueFi-Protocol/contracts-helium: TrueFi smart contracts second release 2022.GitHub
    After this date, TrueTrading will recover the remainder of funds.

    You may want to wait until gas prices are low before calling the redeem( ) function.

    Step-by-step

    1. Check your balance of shares here:

    In this example, the address 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F has a balance of 73,990.677577, which means it can claim 73,990.677577 USDC. There should be six digits after the decimal point.

    1. Connect your wallet to Etherscan on this page by clicking the “Connect to Web3” button as indicated below:

    2. Click, “Contract” and “Write as Proxy”, then call the redeem() function (#9, 0xba087652):

    For shares, enter your balance from #1 (but drop the decimal point and any commas): 73990677577 in the example.

    For both receiver and owner, enter your wallet address from #1: 0x168151e53210Bbb08Fa6AfAC15E3da185e66069F in the example.

    1. Review this transaction carefully, click Write, and then confirm via your wallet.

    Support

    If you have any questions or need assistance, please contact [email protected].

    Please reach out to [email protected] if you have a smart contract with claimable airdrop balance, but no ability to call redeem(). If you can prove ownership of the contract, they may be able to work out a way for you to receive your share.

    0x044e3e0a83453d6F673170953fdA6Ed725adB286
    external audit by ChainSecurity

    Managed Portfolio [legacy]

    ManagedPortfolio is in the process of being sunset.

    New TrueFi Capital Markets portfolios deployed after June 2022 use contractFlexiblePortfolio

    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​

    Method
    Notes

    View Methods

    Method
    Notes

    Typical Flows 🌊

    Below are examples of typical flows in TrueFi Capital Markets pools:

    • Manager creates ManagedPortfolio using ManagedPortfolioFactory.

    • Lender lends funds into the ManagedPortfolio.

    Additional actions that might happen:

    • Manager can change loan parameters (with a Borrower's approval if necessary).

    • Manager can set loan status to Defaulted if Borrower does not return funds on time (and eventually set loan status to Resolved once the debt is settled).

    BulletLoans is an ERC-721 contract. Each of the tokens represents a single loan. All the loan parameters can be read from LoanMetadata struct. BulletLoans contract enables loan creation, facilitates loan repayment and allows managing the loan's state and parameters.

    ManagedPortfolio is an ERC-20 token facilitates funds management and allows loan issuance. Portfolio tokens represent lenders' share in the pooled funds. All of the portfolio operations are up to the managers discretion. Manager makes the decisions about issuing new loans, marking them as defaulted, altering portfolios params and so on. Lenders only lend funds into the portfolio if they trust the manager is going to abide by a reasonable policy. 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). Funds from the portfolio are only available for the withdrawal after the final closing date.

    ManagedPortfolioFactory

    Contract that allows easy portfolio configuration and creation. A particular instance of the factory can only be accessed by whitelisted addresses.

    ProtocolConfig

    Contract holding key system params.

    BorrowerSignatureVerifier

    A contract that verifies borrower's consent to change the loan parameters. Manager can freely change the loan parameters in borrower's favour (reduce owned amount, increase time), but needs an explicit, borrower's approval to do the opposite.

    ILenderVerifier

    Whitelist

    A contract that implements simple, universal whitelist.

    WhitelistLenderVerifier

    A 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

    A contract that requires lender to provide a signature of a predefined message.

    contracts-ragnarok/contracts/ragnarok/BulletLoans.sol at main · TrueFi-Protocol/contracts-ragnarokGitHub

    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.

    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.

    Returns total estimated value of portfolio (liquidValue + illiquidValue).

    Manager issues a BulletLoans token to the ManagedPortfolio (portfolio sends funds to the Borrower).
  • Borrower repays BulletLoans an owed amount (BulletLoans will send funds to the debt owner - in this case the ManagedPortfolio).

  • Lender withdraws funds from the ManagedPortfolio.

  • Manager can change various ManagedPortfolio properties.

    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.

    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.

    BulletLoans
    ManagedPortfolio

    setEndDate(uint256 newEndDate)

    value()

    SignatureOnlyLenderVerifier: contract that requires the lender to provide a signature of a predefined message.
    Logo
    Logo

    Developer docs

    [Legacy] TrueFi DAO pools contracts

    Below is a brief guide to TrueFi lending pool contracts.

    For detailed questions, please reach out to the Discord #dev channel.

    Lending pool addresses

    Contract Name
    Address

    TrueFi DAO Pool contracts

    • : lenders provide and withdraw liquidity to the pool, and can get lending pool details, such as pool value, pool token price, etc. from this contract

    • : implements the lending strategy for the TrueFi pool, i.e. how loans are approved and funded

    • : deploys LoanTokens, which represent details of each loan on-chain

    TrueFiPool2 contract

    The TrueFiPool2 contract is used by TrueFi DAO lending pools -- tfUSDC / tfUSDT / tfBUSD / tfTUSD. This contract enables accounts to pool tokens with the goal of earning yields on underlying tokens.

    Contract Name
    Address

    Lending & Withdrawing methods

    Method
    Notes

    Determining pool values

    Calculating LP token price

    To calculate the price of the lending pool token ("LP token"), take poolValue() divided by totalSupply() .

    Calculating pool APY

    To calculate yield for a pool, one must calculate the weighted average of rates across each active loan in the pool and idle funds held in the pool.

    pool_apy = SUM(loan_1_amount*loan_1_apy + ... + loan_n_amount*loan_n_value) / poolValue()

    For an example of how this can be done via SQL, see .

    Method
    Notes

    Default handling

    Read more about default handling in

    Method
    Notes

    TrueLender2 contract

    Implements the lending strategy for the TrueFi pool, i.e. how loans are approved and funded.

    Contract Name
    Address
    Method
    Notes

    Loan Token contracts

    Loan tokens are created by .

    Contract Name
    Address

    Each LoanToken has the following parameters:

    • borrower(): address of borrower

    • amount(): principal amount of fixed term loan

    • term(): loan term in seconds

    Method
    Notes

    Repaying loans to lending pools has two steps:

    1. Borrower repays funds to loan token

    2. reclaim() function is called on loan token, which burns the loan token and pays out fees to stkTRU.

    TrueRatingAgencyV2

    As described , the TrueRatingAgencyV2 contract determines whether a loan request should be funded by TrueLender2.

    Contract Name
    Address

    stkTRU holders can vote yes() or no() on each loan. The TrueLender2 contract then checks to see if each loan satisfies threshold conditions in order to be funded.

    stkTRU voters receive rewards in the form of TRU tokens for voting on loan requests. claimable() reward tokens are calculated as follows:

    claimable() = (# TRU voted by user / # total TRU votes) * (Total TRU Reward), where

    • Total TRU Reward = (Loan interest * TRU distribution factor * rewardMultiplier)

      • where Loan interest = (loan APR * term in days * principal) /365. Loan APR, term, and principal can be obtained from the respective loan token contract

      • rewardMultiplier can be found from the

    TrueMultiFarm

    As described , lenders can stake LP tokens into the TrueMultiFarm contract to get TRU rewards.

    Contract Name
    Address

    How to calculate lender emissions per day

    • Total TRU emissions per day can be calculated using totalAmount() and duration() found on the :

      • TRU distribution per day = (totalAmount/10^8) / (duration/(24*3600))

    • To calculate farm rates for each token, use the formula below:

    Method
    Notes

    Logo
    TrueRatingAgencyV2: loan applications are rated and approved by TRU stakers
  • TrueMultiFarm: lenders can stake lending pool tokens to earn TRU rewards (read more here)

  • SAFU: handles bad debt in TrueFi lending pools (read more here)

  • Calculates lender will pay to withdraw liquid funds from the pool. This returns a proportion to be applied if liquidExit() is performed with the given amount of LP tokens.

    For example, when a pool is at ~75% utilization a small withdrawal would return liquidExitPenalty = ~0.9980, meaning that the lender would pay an exit penalty of ~0.20% (20 bps) to withdraw from the pool.

    For more detail on liquid exit and how the penalty is calculated, see .

    averageExitPenalty(uint256 from, uint256 to)

    Internal function for calculating exit penalty.

    apy(): loan APR in basis points (i.e. 971 = 9.71%)

  • status(): returns loan's status, which progresses through the following states:

    • 0 --> Awaiting: Waiting for funding to meet capital requirements

    • 1 -->Funded: Capital requirements met, borrower can withdraw

    • 2 -->Withdrawn: Borrower withdraws money, loan waiting to be repaid

    • 3 -->Settled: Loan has been paid back in full with interest

    • 4 -->Defaulted: Loan has not been paid back in full

    • 5 -->Liquidated: Loan has Defaulted and stakers have been Liquidated

  • canTransfer(): returns LoanTokens are non-transferable except for whitelisted addresses

  • debt(): returns amount + interest. Note that this does not take into account whether the loan has been repaid.

  • isRepaid(): returns boolean value, indicating whether a loan has been repaid in full.

  • profit(): returns difference between debt() and amount(), the anticipated interest to be paid on the loan

  • Function for borrower to reclaim any underlying currency stuck in the loan token contract. Only the borrower can call this function after the loan has been settled, defaulted, or liquidated.

    contract
  • TRU distribution factor is calculated as remaining divided by amount from the RatingAgencyV2Distributor contract

    • TRU rewards per farm per day = TRU distribution per day * getShare(IERC20 token) / shares() as described below

    Returns denominator for total farm rewards rate

    getShare(IERC20 token)

    Returns numerator for LP token's share of farm rewards

    tfUSDC

    0xA991356d261fbaF194463aF6DF8f0464F8f1c742

    tfUSDT

    0x6002b1dcB26E7B1AA797A17551C6F487923299d7

    tfTUSD

    ​0x97cE06c3e3D027715b2d6C22e67D5096000072E5

    tfBUSD

    0x1Ed460D149D48FA7d91703bf4890F97220C09437

    TrueFiPool2

    0x8d35372ea3e85c49a60f0a72edeff8629da3999a

    join(uint256 amount)

    Lends a certain amount of underlying tokens to the portfolio, and mints and transfers corresponding amount of ERC-20 lending pool ("LP") tokens to the lender.

    liquidExit(uint256 amount)

    Withdraws liquidity from the lending pool. Lender transfers pool tokens to pool and receives underlying token, but with a small penalty for liquidity as calculated by

    liquidExitPenalty() described below.

    poolValue()

    Returns pool value in underlying token.

    This is the virtual price of the entire pool, including values for loan tokens and liquid underlying tokens held by the pool.

    Note: this assumes defaulted loans are worth their full value.

    liquidValue()

    Returns virtual value of liquid assets in the pool.

    totalSupply()

    Returns total number of pool LP tokens.

    liquidRatio()

    Ratio of liquid assets in the pool to the pool value, in basis points. For example, 4683 => 46.83%.

    utilization()

    Returns utilization in basis points. For example, 5316 => 53.16%.

    Calculated as 1 - liquidRatio().

    liquidate(ILoanToken2 loan)

    Calls SAFU function to liquidate bad debt. Liquidates a defaulted Loan, withdraws a portion of TRU from staking pool then tries to cover the loan with own funds, to compensate lending pool. Loan must be in defaulted state. If SAFU does not have enough funds, deficit is saved to be redeemed later.

    reclaimDeficit(ILoanToken2 loan, uint256 amount)

    After a defaulted loan's debt has been redeemed by the SAFU, the lending pool can reclaim call this function to redeem "deficiency claim" tokens for underlying tokens held in the SAFU.

    TrueLender2

    0xa606dd423dF7dFb65Efe14ab66f5fDEBf62FF583

    fund()

    When called, sends funds from the pool to the loan token contract. Pool receives and holds loan tokens. Must be called by the loan borrower.

    loanIsCredible(uint256 yesVotes, uint256 noVotes)

    Checks whether loan receives sufficient votes via stkTRU rating to be funded. Checks whether loan receives minimum ratio of yes to no votes and hits threshold of minimum votes set by owner.

    reclaim(ILoanToken2 loanToken, bytes calldata data)

    Redeems LoanTokens held by the pool for underlying funds held in the loan token. Loan token must be settled before calling this function.

    reclaimDeficit(ILoanToken2 loan, uint256 amount)

    After a defaulted loan's debt has been redeemed by the SAFU, the lending pool can reclaim call this function to redeem "deficiency claim" tokens for underlying tokens held in the SAFU.

    LoanFactory2

    0x69d844fB5928d0e7Bc530cC6325A88e53d6685BC

    fund()

    Transfers tokens to loan token contract from pool. Can be called only by lender contract. Sets status to Funded, start time, lender.

    withdraw(address _beneficiary)

    Borrower calls this function to withdraw funds to address provided. This sets the status of the loan to Withdrawn.

    repayInFull(address _sender)

    Function for borrower to repay all of the remaining loan balance. Borrower should use this to ensure full repayment.

    _repay(address _sender, uint256 _amount)

    Internal function for loan repayment. If _amount is sufficient, then this also settles the loan.

    settle()

    Moves loan to status = 'settled' if loan is fully repaid.

    TrueRatingAgencyV2

    0x05461334340568075bE35438b221A3a0D261Fb6b

    TrueMultiFarm

    0xec6c3FD795D6e6f202825Ddb56E01b3c128b0b10

    LinearTrueDistributor

    0xc7AB606e551bebD69f7611CdA1Fc473f8E5b8f70

    stake(IERC20 token, uint256 amount)

    Stake tokens to the farm. Upon staking, this will claim any claimable rewards.

    unstake(IERC20 token, uint256 amount)

    Remove staked tokens

    claim(IERC20[] calldata tokens)

    Claim TRU rewards

    exit(IERC20[] calldata tokens)

    Unstake amount and claim rewards

    claimable(IERC20 token, address account)

    Returns the claimable TRU reward for an account that is staking tokens.

    TrueFiPool2
    TrueLender2
    LoanFactory2
    this Dune query
    LoanFactory2
    here
    here
    distributor contract
    SAFU default handling

    liquidExitPenalty( uint256 amount )

    reclaim()

    shares()

    TrueRatingAgencyV2
    here
    contracts-ragnarok/contracts/ragnarok/ManagedPortfolio.sol at main · TrueFi-Protocol/contracts-ragnarokGitHub
    Logo