Navigating Basic Loan Liquidations in the Hoyu Protocol
In this blogpost, we discuss Hoyu’s approach to loan liquidations and provide two worked-out examples of how the protocol liquidates loans.
Hoyu Recap
Hoyu is a protocol that strives to improve Lending Markets by integrating them with Trading Markets. Hoyu’s features include allowing any token to serve as collateral at a 90% Loan-To-Value, risk protection for passive lenders, and true decentralization, with no dependency on external price oracles or liquidators.
Trading and Lending Markets
The Hoyu protocol enables Trading and Lending Markets for any two tokens:
- A Trading Market enables swapping one token for another token, that is, buying and selling tokens. This market allows its participants to converge on the price of one token in terms of another token. This is also known as a Decentralized Exchange (DEX) or an Automated Market Maker (AMM) protocol.
- A Lending Market allows one token to be used as collateral which then enables borrowing another token. This market allows its participants to converge on a spot interest rate for the token pair. This is also known as a Money Market or a Lending Protocol among other names.
In Hoyu, the Trading Market and the Lending Market for a particular token pair always come together, since one cannot operate without the other. Together they make up a comprehensive Market for a particular token pair. Markets for distinct token pairs are completely independent from one another.
Two Liquidation Criteria
Loan liquidation mechanics is an aspect of any lending protocol that is especially crucial for its users to understand. The term "loan liquidation" refers to the process by which a borrower's collateral is sold off or "liquidated" when certain conditions occur. In Hoyu, this is carried out by the smart contracts of the protocol, as opposed to external liquidators. The liquidations happen as a side effect of various actions, including swaps on the Trading Market. The protocol only liquidates loans when at least one of the two conditions is violated:
- Breach of the Loan-to-Value (LTV) ratio of the loan
- Breach of the general Liquidity Limit In the next sections we address LTV and Liquidity Limit breaches more explicitly and with examples. We leave certain details out for simplicity. In particular, loan interest details, additional requirements for loan originations, as well as surplus collateral mechanics discussion is left for future posts.
Loan-to-Value
The LTV ratio is widely used to assess risk in lending. It essentially compares the size of the loan to the value of the collateral using some price. The Hoyu protocol uses the spot price of the collateral token in terms of the other token in the pair.
Collateral Ratio (CR) is a related term, which is simply the inverse of LTV. For example, a loan with an LTV of 50% has a Collateral Ratio of 200% since 1/0.5=2. The lower the LTV and the higher the CR, the more well covered the loan.
In Hoyu's case, if one were to provide collateral in the form of a certain token, one could borrow up to 90% (CR of 110%) of its current market value in another token, like a stablecoin. While the LTV requirements are present in virtually every DeFi Lending Market, LTV this high is rare. Most protocols offer much lower LTV to account for price volatility and protect the lenders against potential losses. Hoyu is able to maintain loans with high LTV because of the direct flow of up-to-date price information from the Trading Market to the corresponding Lending Market.
The integrated Trading Market on Hoyu is a smart contract where users can swap one token for another, just like in UniswapV2 and similar DEXes. Some users act as liquidity providers by depositing their tokens, which other users can trade against. So how does this affect the liquidation process? The Trading Market on Hoyu provides timely data on both the liquidity level and spot price of collateral tokens to the associated Lending Market. The spot price is then used to determine the LTV of each loan and make sure that each loan is properly covered by its collateral.
Example 1: LTV breach
TLDR of this LTV example with stick figures
Consider a Market that serves a pair of tokens and operates with a Liquidity Limit of 7.8% (more on this magic number in future posts!). As mentioned above, we ignore interest and do not discuss what happens to surplus collateral in these examples for the sake of simplicity. The pair of tokens consists of Altcoin (ALT) and Currency (CUR). Let’s say that the Trading Market currently has 1000 CUR and 1000 ALT as its Reserves, allowing CUR<>ALT swaps. A lender adds 50 CUR to the Lending Market. This Currency is now available for borrowing.
A borrower comes along, deposits 56 ALT as collateral, and borrows 50 CUR. That is just barely possible since the borrower uses all the Currency in the Lending Market. Also, this loan is just barely collateralized at the moment, its LTV is 89% since the price is 1.0 CUR/ALT. In contrast, the Liquidity Limit is well respected as 50CUR/1000CUR=5%<7.8% (see the next sections for more on the Liquidity Limit).
Next, a trader sells 50 ALT. Ignoring the loan, the trade would yield 47 CUR and push the price down to 0.91 CUR/ALT. However, if that happened, the LTV of the loan would go up to 98%=50 CUR / (56 ALT * 0.91 CUR/ALT), which is already above 90%.
Since the LTV requirement breach is not allowed, the protocol first liquidates the loan, and only then executes the trade. Both of these actions happen in the same transaction. Repaying 50 CUR requires swapping 53 ALT of the 56 ALT collateral using the initial reserves. The reserves after the liquidation are 950 CUR and 1053 ALT. The trader’s swap is executed with these post-liquidation reserves, such that the trader gets 43 CUR for their 50 ALT. After this transaction, there are no loans outstanding anymore, since the only loan got liquidated.
We have illustrated the LTV criterion and provided an example of an LTV-breach-prompted liquidation initiated by a swap on the Trading Market. In addition to the LTV criterion, the protocol also evaluates the Liquidity Limit, which we discuss next.
Liquidity Limit
The Hoyu Trading Markets provide both price and liquidity data to their corresponding Lending Markets. Here, liquidity is defined as the quantity of tokens deposited into each Trading Market, such that each token pair has a unique liquidity level. The depth of this liquidity determines the potential price impact of a transaction, and consequently, the maximum collateral that can be safely liquidated. Hence, in assessing the health of the lending protocol and deciding on loan liquidation, Hoyu's smart contracts factor in both the collateral price and the liquidity of the relevant Trading Market. This is different from most other Lending Markets that operate without any access to liquidity information. We now proceed to work out an example where a liquidation happens due to the Liquidity Limit breach.
Example 2: Liquidity Limit breach
TLDR of this Liquidity Limit example with stick figures
Consider once again a Market that serves the same pair of CUR and ALT tokens with the same Liquidity Limit of 7.8%. The Trading Market starts out with the Reserves of 1000 CUR and 1000 ALT. A lender adds 100 CUR to the Lending Market.
A borrower comes along and deposits 100 ALT as collateral and borrows 77 CUR. That is possible since the borrower uses part of the Currency in the Lending Market. This loan is well collateralized at the moment, its LTV is 77%<90%. However, the Liquidity Limit is just barely respected as 77CUR/1000CUR=7.7%<7.8%.
As in the previous example, a trader sells 50 ALT. Ignoring the loan, the trade would again yield 47 CUR and push the price down to 0.91 CUR/ALT and the Currency reserve down to 953 CUR. If that happened, the LTV of the loan would go up to 85%<90% but remain compliant with the LTV criterion. However, the Liquidity Limit would be violated since 77CUR/953CUR=8.1%>7.8%.
Since the Liquidity Limit requirement is breached, the protocol first liquidates the loan, and only then executes the trade. Once again, both of these actions happen in the same transaction. Repaying 77 CUR requires swapping 84 ALT of the 100 ALT collateral using the initial reserves. The reserves after this liquidation are 923 CUR and 1084 ALT. The trader’s swap is executed with these post-liquidation reserves, such that the trader gets 41 CUR for their 50 ALT. After this transaction, there are no loans outstanding anymore, since the only loan got liquidated, and the protocol is back to a healthy state.
Conclusion
In this blogpost, we have discussed elements of the liquidation mechanics in the Hoyu protocol. In addition to the Loan-to-Value ratio particular to each loan, we have also introduced the Liquidity Limit which applies to all the outstanding loans in a given Market. Two worked out examples illustrated the application of these conditions in the case of a liquidation of a single loan.