Implementing the functions for user requests
In Figure 11.2, there are eight user requests shown in an architecture diagram for crypto loan smart contracts. These user requests are fulfilled by calling the functions of an asset pool smart contract. There are two privilege requests that are already implemented in the Implementing the code to manage the asset pools section of this chapter. The remaining six requests (deposit, withdraw, borrow, repay, liquidate, and withdraw reserve) require a change of liquidity balances for the asset pools. We will deep dive into the functions for handling these requests in this section.
Depositing
A deposit process requires the AssetPool
smart contract to transfer tokens from a user to the smart contract and mint the asset pool share tokens to the user. Figure 12.2 describes the workflow of the deposit process.
Figure 12.2 – The workflow of the deposit process
Based on the preceding workflow, we can implement...