ISheep

ISheep

Badminton | Coding | Writing | INTJ
github

Borrowing and lending - On Chain

Credit - a magical tool of the modern financial system, and also a major factor in the formation of economic cycles.

Traditional lending

Traditional lending generally includes credit lending (social security records, bank card transactions), mortgage lending (real estate, cars), etc. The roles involved usually include borrowers, lenders, and liquidators, and the liquidation and lending caused by defaults are usually handled by banks. However, the process is extremely slow, such as the liquidation of real estate, which is inefficient and complex in the process of foreclosure.

On-chain lending

Stablecoins, synthetic assets (aToken, cToken, yToken, etc.) are all based on this.

Roles

Lending Roles

The four roles interact with the treasury (smart contract) to form a decentralized lending system. The role of the liquidator in traditional lending is usually played by banks, and if the borrower cannot repay the money, it will be handed over to the liquidator.

Case Study - MakerDAO

MakerDAO is the parent company that mints $DAI.

Preceding term explanations:

  1. Liquidation threshold: Collateral value * Liquidation threshold = Borrowing capacity (maximum amount that can be borrowed)
  2. Health factor: Collateral value * Liquidation threshold / Debt > 1 is healthy, less than 1 can be liquidated
  3. Liquidation ratio: The proportion of collateral that liquidators can liquidate at once

Assuming a liquidation threshold of 0.75 and a liquidation ratio of 0.5, with 1 ETH = 2000 DAI, I can borrow a maximum of 1500 DAI by mortgaging 1 ETH (but borrowing 1500 DAI is risky, as a slight drop in ETH can lead to liquidation). So I borrow 1250 DAI. At this time, the health factor is 1.2. When the ETH price drops to 1600, the liquidation threshold is 1200 DAI, and the health factor is 0.96 < 1, the collateral will be liquidated by the liquidator.

Liquidation

It is generally divided into two categories: fixed spread liquidation and auction liquidation (which can be further divided into Dutch auction and English auction). Liquidation is profitable, with a liquidation spread, and MakerDAO's spread is 13%. Generally, liquidation does not directly provide a UI operation entry, and it is operated by liquidation smart contract robots.

Fixed spread liquidation

Liquidators can liquidate debts with health factors less than 1 from the contract, obtain collateral from the contract treasury, and repay a portion of the corresponding debt, so that the borrower's health factor is greater than 1. The liquidation can only liquidate collateral in a proportion not exceeding the liquidation ratio. In the past, platforms like AAVE had instant liquidation, but now there is a buffer time for borrowers to add collateral, which may be 12 hours / 24 hours.

Auction liquidation

Auction liquidation involves a lengthy on-chain process. The contract defines an auction time period and conducts auctions based on different auction types, continuously accepting bids from liquidators until the auction ends (English auction).

Flash loans

AAVE supports flash loans, but the requirements are high and need to be completed in one transaction. Generally, it can only be done by writing a contract and completing all the logic in one function.

For example, if the decentralized exchange Dex A has ETH/USDT = 1200 and Dex B has ETH/USDT = 1150, I borrow 5000 USDT from AAVE, buy on B, sell on A, and finally repay, completing an arbitrage in one transaction.

However, in reality, flash loans are often exploited by hackers. For example, some decentralized exchanges that support contract use Uniswap's price estimation interface. They open an empty position, borrow ETH to dump on Uniswap, then close the contract to profit and return the ETH. This kind of flash loan attack behavior is very malicious.

Revolving loans

The coins borrowed from the lending protocol can also be used to buy collateral on other exchanges and borrow again. Revolving loans have high risks and may cause a deleveraging spiral liquidation (as liquidation involves selling collateral, which is a market-dumping behavior).

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.