Managing records in user ledgers
In the crypto loan system in this book, we use the concept of asset pool share tokens to represent the user’s position in an asset pool. Once a user deposits a token to an asset pool, the user will receive the asset pool share token for the token; we call the user who deposits the token a lender. Later on, the lender can redeem the original token by sending the asset pool share token back to the asset pool smart contract.
Since we use the pool share token to represent lenders’ positions, how could we represent loan positions for borrowers? The answer is that we don’t issue any tokens to borrowers, but we record the borrowed shares in user ledgers to represent the loan for borrowers. As time goes by, although the amount of borrowed shares doesn’t change, the borrowed shares will become more valuable, so the borrowers will need to pay more interest to pay off the loans.
In order to store the amount of borrowed shares...