Lines of Credit contracts
AutomatedLineOfCreditis a contract that serves as a lending pool of funds managed by the borrower, who is the sole party who can borrow the funds. The borrower can: borrow funds, repay funds, set
AutomatedLineOfCreditmax size, add/remove deposit strategies, add/remove withdraw strategies, and change the transfer strategy. The borrower can also upgrade the AutomatedLineOfCredit implementation.
When a borrower repays a given amount of borrowed funds, they owe interest. This interest is added to their balance of the outstanding debt. The amount of interest they owe is based on the utilization rate of the funds in the
AutomatedLineOfCreditat the time they repay a given amount of debt. The interest rate that the Borrower pays on their funds is a function of the utilization of the
AutomatedLineOfCredit. This function is parameterized by six values which are determined by the borrower when the
- A (1) minimum interest rate utilization threshold up to which point the interest rate is equal to the (2) minimum interest rate,
- An (3) optimum utilization rate and (4) optimum interest rate. The interest rate is determined by linearly interpolating between the minimum interest rate and the optimum interest rate when the utilization rate is between the minimum interest rate utilization threshold and the optimum utilization rate,
- A (5) maximum interest rate utilization threshold beyond which the interest rate is equal to the (6) maximum interest rate. The interest rate is determined by linearly interpolating between the optimum interest rate and the maximum interest rate when the utilization rate is between the optimum utilization rate and the maximum interest rate utilization threshold.
utilizationof an AutomatedLineOfCredit is equal to:
(borrowed_funds + unpaid_interest) / value
valueof an AutomatedLineOfCredit is equal to:
liquid_funds_in_ALOC + borrowed_funds + unpaid_interest - unclaimed_fees
When the Borrower borrows from the
utilizationincreases. When a Lender deposits into the
utilizationdecreases. When a Lender withdraws from the
Whenever an action that changes
AutomatedLineOfCreditvalue is performed (
updateAndPayFee), a fee for the TrueFi DAO is calculated and immediately transferred to the TrueFi DAO Treasury address. The fee is deducted from the
AutomatedLineOfCreditvalue, so actions like
redeemcannot 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.
accruedFeevalue is equal to:
(current_timestamp - last_update_timestamp) / YEAR * protocol_fee_rate * portfolio_value
portfolio_valuedoes not take into account the interest that has been accrued since the last update.
protocol_fee_rateis the rate taken from the
ProtocolConfigcontract the last time an update was made. This means that if the DAO decides to increase the fees, the higher rate will be applied for
accruedFeecalculation since the next update, not the current one.
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.
AutomatedLineOfCreditFactoryserves for deploying new AutomatedLinesOfCredit. All of the
AutomatedLineOfCreditparameters are chosen by the borrower, except for