ISheep

ISheep

Badminton | Coding | Writing | INTJ
github

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, automobiles), and so on. The roles involved usually include borrowers, lenders, and liquidators, with defaults and lending generally handled by banks. However, the process is extremely slow, such as the liquidation of real estate, which is inefficient and complex in foreclosure procedures.

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 a bank, and if the borrower cannot repay the money, it will be handed over to the liquidator.

Case - 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 percentage 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 carries high risk, as a slight drop in ETH value 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, so the collateral will be liquidated by the liquidator.

Liquidation

There are generally two types: fixed spread liquidation and auction liquidation (which can be further divided into Dutch auctions and English auctions). Liquidation is profitable, with a liquidation spread, and MakerDAO's spread is 13%. Generally, liquidation does not have a direct 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, ensuring that the borrower's health factor is greater than 1. They can only liquidate collateral proportions that are not greater than the liquidation ratio. Previously, protocols like AAVE had instant liquidation, but now there is a buffer time for borrowers to add collateral, which may be 12h / 24h.

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 a single transaction. Generally, one needs to write a contract and complete all the logic in one function.

For example, if there is a decentralized exchange Dex A with ETH/USDT = 1200 and Dex B with ETH/USDT = 1150, I can 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 have been exploited by many 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

Coins borrowed from lending protocols can also be used to buy collateral on other exchanges and borrow again. Revolving loans carry 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.