Functional Overview

This section explains, at high.-level what are the functional relations between the different components of the system for taking out a loan in Concrete.

How does taking out a loan with Concrete work?

The following diagram shows, at a high level, the interactions that occur in the system when a user takes out a loan through concrete.

Figure 1 - Taking out a loan with Concrete, system components relations.

When a borrower initiates the creation of a loan through Concrete this is what happens in the system.

  1. The frontend triggers the Supply flow calling the backend borrower service.

  2. The backend smart contract execution service handles this call by interacting with the protocol's smart contracts functions.

  3. The backend updates the loan LTV and foreclosure price based on the real-time collateral price data and probability engine outputs.

  4. The frontend triggers the Borrow flow through the backend borrower servicchercke to the smart contracts.

  5. The loan is successfully created in the lending platform by the Concrete smart contracts on behalf of the borrower.

User Flow

To take out a loan through Concrete, a borrower, will need to follow these steps:

  1. Search available lenders by

  • Chain

  • Collateral asset type

  • Loan asset type

  • Connect wallet In order to continue with the flow, the user will be required to connect their web3 wallet by clicking on the "Connect Wallet" button. This will allow Concrete the ability to get user's wallet balance from the supported networks, handle interactions with smart contracts and signing messages.

  1. Choose a lending platform At this part of the flow, the user will pick which of the lending platforms they will take out the loan on. For understanding how the system works, the frontend gets lenders data from the borrower backend service which has been pre-registered with the available lenders and frequently refreshes the corresponding parameters like Max LTV and APRs. It is planned that this data will be picked up from a subgraph

  2. Enter the collateral and loan amounts In this step, the user will enter the amount of the collateral and loan amount. At a UI level, the frontend calculates and displays the LTV (Loan-to-Value) ratio using the price of the collateral which comes from the backend (exposed by the borrower service that consumes it from the price oracle service). Also, the frontend will pull the balance of the corresponding collateral asset from the user's wallet and will validate maximum inputs considering Max LTV for the chosen lender and available balance. Given that price of the collateral might fluctuate while the user is entering the collateral and loan amounts, the calculations will refresh periodically (initially every 30 seconds).

  3. Supply the collateral This is a key step of the borrow flow, as it is the first trigger that will generate an interaction with the protocol smart contracts. After the user clicks on the "Supply" button, a sequence of interactions occur between some components of the system: -Backend --Borrower Service --Smart Contract Execution Service --Smart Contract Monitor Service Smart Contracts --Borrow Flow ---Supply (onboard, supplyToLender, mintLoanToken functions) Refer to Figure 2 in the next step that explains, at a high level, the pattern of interactions between these components. In more detail, this is what the experience looks like for the user and what happens behind the scenes.

  • User is prompted to approve interaction between their wallet and Concrete smart contracts. To do this, the user signs a transaction from their web3 wallet.

  • [UNDER CONSIDERATION] In order to facilitate the UX, Concrete will request approval to set allowance to maximum. This will make it easier for the user the next time they want to borrow, so the protocol can seamlessly deduct the amount required to be supplied without the need to approve a transaction again.

    Note: The user can choose to change the allowance amount at any given time and this is clearly explained in the UI.

  • User confirms to supply the funds on the UI

  • User is prompted to transfer the collateral to the protocol wallet, then the smart contracts will mint a portfolio token (onboard function), send the funds to the lender (supplyToLender) and a mint loan token to the user wallet (mintLoanToken). Note: Portfolio token is minted only the first time a user takes out a loan, then all loans are attached to that portfolio token.

  1. Confirm the loan creation (borrow) After the collateral is supplied, the transactions mentioned above need to settle on the blockchain. As this may take some time, the price of the collateral asset could fluctuate during that period and the final LTV or loan amount may change. At a UI level, the user will only be able to proceed with the creation of the loan once the Supply flow is finished. During this time, the "Take Loan" button is disabled on the UI and the loan terms may update. Once the backend confirms (through the smart contract monitor service) that the supply function was executed correctly and a loan token was minted to the user wallet, the "Take Loan" button enables and the user can proceed with the creation of the loan. At this moment the Borrow flow is executed and a similar pattern of interactions, as the in the Supply flow. (see Figure 2).

Figure 2 - Supply and Borrow frontend-backend-smart contracts interaction pattern
  1. Successful loan creation Once the creation of the loan succeeds, the user is prompted to protect their loan. Until the loan is not protected, it is identified internally as an Unprotected Loan. For further understanding the protection flow, browse the Loan Protection section.

Edge cases

The step-by-step process described above considers a happy path where user complete the flow end to end.

A few edge cases have been identified and addressed in the following way.

Loan Creation not confirmed

After supplying collateral, if the user does not confirm the creation of the loan, an uncovered loan will be created by the protocol with a loan amount of zero.

In this case, if the user wants to take the loan later, from the loan portfolio section on the UI, the user can enter the loan amount with the "Borrow" action and complete the loan.

In case the user decided to not take out the loan after supplying the collateral, they can just close the loan, the protocol will retrieve the collateral and make it available to the user.

[Add other edge cases here]

Last updated