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
  • Lending pool addresses
  • TrueFi DAO Pool contracts
  • TrueFiPool2 contract
  • Lending & Withdrawing methods
  • Determining pool values
  • Default handling
  • TrueLender2 contract
  • Loan Token contracts
  • TrueRatingAgencyV2
  • TrueMultiFarm

Was this helpful?

Export as PDF
  1. TrueFi Protocol
  2. Other concepts
  3. [Legacy] DAO pools

Developer docs

[Legacy] TrueFi DAO pools contracts

PreviousRisk MitigationNextOther legacy contracts

Last updated 1 year ago

Was this helpful?

Below is a brief guide to TrueFi lending pool contracts.

For detailed questions, please reach out to the channel.

Lending pool addresses

Contract Name
Address

tfUSDC

tfUSDT

tfTUSD

tfBUSD

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

  • : loan applications are rated and approved by TRU stakers

  • : lenders can stake lending pool tokens to earn TRU rewards (read more )

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

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

TrueFiPool2

Lending & Withdrawing methods

Method
Notes

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.

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()

Method
Notes

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().

liquidExitPenalty( uint256 amount )

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.

averageExitPenalty(uint256 from, uint256 to)

Internal function for calculating exit penalty.

Default handling

Method
Notes

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)

TrueLender2 contract

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

Contract Name
Address

TrueLender2

Method
Notes

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)

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)

Loan Token contracts

Contract Name
Address

LoanFactory2

Each LoanToken has the following parameters:

  • borrower(): address of borrower

  • amount(): principal amount of fixed term loan

  • term(): loan term in seconds

  • 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

Method
Notes

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.

reclaim()

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.

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

Contract Name
Address

TrueRatingAgencyV2

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

TrueMultiFarm

Contract Name
Address

TrueMultiFarm

LinearTrueDistributor

How to calculate lender emissions per day

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

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

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

Method
Notes

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.

shares()

Returns denominator for total farm rewards rate

getShare(IERC20 token)

Returns numerator for LP token's share of farm rewards

​

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

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

Read more about default handling in

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

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

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

Loan tokens are created by .

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

rewardMultiplier can be found from the contract

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

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

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

âš¡
this Dune query
LoanFactory2
here
TrueRatingAgencyV2
RatingAgencyV2Distributor
here
distributor contract
Discord #dev
here
here
TrueFiPool2
TrueLender2
LoanFactory2
TrueRatingAgencyV2
TrueMultiFarm
0xA991356d261fbaF194463aF6DF8f0464F8f1c742
0x6002b1dcB26E7B1AA797A17551C6F487923299d7
0x97cE06c3e3D027715b2d6C22e67D5096000072E5
0x1Ed460D149D48FA7d91703bf4890F97220C09437
0x8d35372ea3e85c49a60f0a72edeff8629da3999a
0xa606dd423dF7dFb65Efe14ab66f5fDEBf62FF583
stkTRU rating
0x69d844fB5928d0e7Bc530cC6325A88e53d6685BC
0x05461334340568075bE35438b221A3a0D261Fb6b
0xec6c3FD795D6e6f202825Ddb56E01b3c128b0b10
0xc7AB606e551bebD69f7611CdA1Fc473f8E5b8f70
SAFU default handling
SAFU
SAFU
here