In this article, we will take you on a trip about liquidation mechanisms from the basic to the most advanced. We will explain what factors are involved in a liquidations mechanism, so that you can understand existing ones, or even design your own.
Lending in DeFi is supported by liquidations, but those often feel like a dark art. Unlike in traditional finance, decentralized liquidations are frequent, instantaneous, and executed by often anonymous operators.
In the early days of DeFi, liquidators were extremely profitable and drove innovations such as flash loans and mempool competition. In parallel, DeFi lenders endured market turmoil that would have vaporized traditional finance firms.
Yet, despite the amount of capital involved and the gravity of the job, the information on how to build a liquidation mechanism is fragmented and scattered. This is an emerging field, and new lenders try different mechanisms to address existing or imagined problems.
In this article, we will take you on a trip about liquidation mechanisms from the basic to the most advanced. We will explain what factors are involved in a liquidation mechanism so that you can understand existing ones, or even design your own.
About Liquidations
As a traditional lender, you want borrowers to repay the loans they take from you. If they don’t do that, you accrue bad debt and can go out of business. A measure that you can take to make sure that borrowers repay their loans is to ask them to lend you something of value in return.
This is called collateral.
If the borrower doesn’t repay their loan, or if the lender considers it unlikely that the loan will be repaid, the lender will sell the collateral and forcibly repay the loan, this is called a liquidation. A traditional lender will employ trusted parties to liquidate insolvent loans and can resort to legal proceedings if necessary to avoid losses.
In decentralized finance there is no legal recourse for not repaying a loan and bad debt will never be recovered. On the other hand, it is possible to know the exact value of collateral at all times. For these reasons, insolvent loans in decentralized finance are liquidated immediately if they are insolvent, instead of waiting for a repayment at a given date.
There is a temptation to consider customers who are not able to repay their loans as undesirable customers and think little of their well-being. However, lenders want to protect these customers, and make the liquidation process as painless as possible, as these could be returning customers.
There is another difference in liquidations between traditional and decentralized finance, and that is that DeFi liquidators are anonymous parties, usually with no vetting involved. We will see how incentives are set so that anonymous liquidators protect the lender from bad debt.It is in the trade off between incentivizing liquidators and protecting users that all liquidation processes are designed.
Solvency
For a loan to be solvent, the collateral value must always be higher than the value of the debt. The relative value of two assets varies with volatility, and a loan that was created solvent might become insolvent later on.
If a loan becomes insolvent the borrower has no incentive to repay their debt, as the value of the collateral they recover is below the value of the debt that they repay. Capital losses can quickly accumulate for a lender, leading to bankruptcy.
To avoid this outcome, lenders will allow the insolvent loan to be liquidated, selling the collateral to liquidators that repay the debt in exchange.
Solvency as a comparison between collateral and debt values
For a lender to remain solvent, basic liquidations could be implemented as follows:
liquidation condition: once the solvency formula is breached, a loan is eligible for liquidation: value(collateral) == value(debt)
liquidation action: all of the collateral supporting a loan is sold for the assets required to repay the debt.
The major flaw of the liquidation process as described is that a loan can only be liquidated when the market value of its collateral is below the market value of the assets required to repay the debt. This is a problem because we need to convince anonymous parties to liquidate the loan, and they won’t do it if there isn’t a profit.
To make sure that liquidators profit, we need to explain the collateralization ratio and make loans overcollateralized.
Collateralization Ratio
The basic liquidation mechanism described in the previous section won’t work with anonymous liquidators, because they won’t profit from it.
An easy way to fix that is to liquidate the loan before it becomes insolvent. If the borrower is required to put in more collateral than would be strictly necessary to cover the value of the debt, liquidators have some time as prices drop to liquidate the loan at a profit.
The collateralization ratio of a loan is defined as the ratio between the value of its collateral divided by the value of its debt. The scenario described above is one of overcollateralized lending where the collateralization ratio is required to be above 1.0.
ratio = value(collateral) / value(debt)
Taking the collateralization ratio into account, we now have a different formula to judge if a loan is healthy and safe from liquidation. Unhealthy loans are still solvent, but eligible for liquidation.
value(collateral) < value(debt) * ratio
A collateralization ratio over 1.0 protects the lender by incentivizing liquidators to repay loans that are in danger of becoming insolvent. However, the collateralization ratio is defined by the expected volatility between the debt and collateral assets. The higher the expected volatility, the larger the collateral ratio must be, to give time to liquidators to act.
For borrowers, getting liquidated on loans with a high collateralization ratio can be very costly. For this reason, this liquidation model has only been implemented in proof-of-concepts such as and , the MakerDAO antecessor.
To be safe, the lender might end up incentivizing the liquidators too much. We will fix that next.
Liquidation Bonus
The lender is now protected against bad debt by the selfish actions of liquidators in repaying risky loans for personal profit.
However, a lender needs to walk the fine line between being solvent itself and attracting borrowers. The higher the collateralization ratio, the safer the lender will be, but the users will bear a higher cost when liquidated.
To manage the trade-offs between liquidator profits, scale of user losses, and lender solvency, liquidation bonuses have been applied . When using a liquidation bonus, the liquidator typically receives additional collateral for the debt that they repay at a configurable factor, usually much less than the collateralization ratio.
Of course, the liquidation bonus itself can be a function of any one of the following:
Total debt or debt repaid
Total Collateral or collateral liquidated
Some other factor
Imagine a loan where 150 units of collateral are used to borrow 100 units of debt, at a collateralization ratio of 1.5. The relative value of collateral to debt falls, and a liquidator steps in to repay the 100 units of debt. Without a liquidation bonus, the liquidator would receive 150 units of collateral, likely registering almost a 50% instant profit.
With a liquidation bonus of 5%, the liquidator would repay 100 units of debt, and receive 105 units of collateral, for a profit of up to 5%. The borrower would have its debt erased and would be able to withdraw the remaining 45 units of collateral, registering only up to a 5% loss.As we add additional factors to the liquidation process, the risk of misconfigurations grows.
With a liquidation bonus, we need to ensure that the minimum collateralization ratio is higher than the liquidation bonus. Otherwise, either the liquidation bonus will never be paid in full, or the lender will become insolvent.
Close Factor
If the liquidation bonus is a factor of the size of the liquidated loan, large borrowers will pay more than small borrowers when they get liquidated. To fix this, lenders will often liquidate only fractions of a loan.
If a solvent but unhealthy loan is divided into two equal parts, and one of them gets liquidated, the borrower will have a loan half the size, plus the collateral from the liquidated half that was not taken as a liquidation bonus. This means that the half loan that still exists is more collateralized than it was before.
The close factor dictates what proportion of a loan should be liquidated, to make liquidations as small as possible while returning the reduced loans to a healthy state. Typically it is defined in instant liquidation mechanism as a static value (e.g. 50%).
Consider an example:
The user borrows $750 worth of some asset, by fronting $1000 worth of collateral
Has an initial collateralization ratio of 1.5, as reflected as account health
The price of collateral falls relative to his debt asset, resulting in him being undercollateralized
In this example, we assume a close factor of 50%. Liquidation bonus is 8%.
Note that in this example, the ETH collateral factor is defined as 75% - if you deposit $1000 worth of ETH, you can take on $750 worth of debt at a maximum.
At the lower collateral price, the collateralization ratio is still above 1.0, and both the user and the lender are solvent. The liquidator obtained $20 of collateral, which we hope was enough to cover his costs and realize a profit.
We can’t always execute a partial liquidation. In some cases, the collateral that is returned to the borrower to make the rest of the loan healthy enough. It might still be unhealthy and be liquidated immediately, or it might be healthy, but be liquidated shortly after because of volatility. In those cases, lenders might choose to ignore the close factor and liquidate the whole loan.
Liquidation Costs
Today, liquidations are closely integrated with several market mechanisms. Liquidators often will obtain the assets to repay debts as a flash loan, which . The flash loan will often be repaid by swapping part of the collateral received in a decentralized exchange, which will incur additional costs such as swapping fees and slippage. Only the remaining collateral after fees counts as a profit.
Liquidators also have to pay for gas to execute the liquidation transactions. It is often the case that liquidations happen in times of high price volatility, when there is strong competition for block space, and gas prices are higher than usual.
Liquidators accrue other costs such as developing and maintaining software that must examine all new blocks in the blockchain to liquidate loans in competition with other liquidators.
The flash loan and trading costs eat into the liquidation bonus factor, which development and maintenance costs are constant. The liquidation bonus factor needs to be higher than the estimated flash loan and trading factors so that loans become more profitable the larger they are.
Please note that we assume liquidation costs to be linear in this graph - this could change in practice.
Throttling
Another factor to consider when thinking about market mechanisms is that of market liquidity.
Upon liquidation, the loan collateral will usually be sold immediately; unless the liquidator is keen to hold a depreciating asset. But this is unlikely. Thus, this raises the concern of available market liquidity for such sales.
Some individuals hold more of a specific asset than its available liquidity; being a recent notorious example. If loans are allowed to be collateralized by amounts that are not easily tradeable, those loans are effectively not liquidatable.
A solution is to put a hard limit on the collateral allowed per loan so that a single liquidation can never exceed the tradable amount of collateral. Even if a borrower would open several loans with maximum collateral, these would be separate liquidations, and the markets would have the chance to process them one by one.
A different solution would be a dynamic close factor, so that large loans are liquidated in smaller parts, with a similar effect.
None of these solutions is perfect, because market liquidity cannot be predicted consistently in advance. Only an integration between a lender and an exchange would allow liquidations to be triggered not only by price variations but also by liquidity variations.
Dust
Once we take gas costs into account, smaller loans become unprofitable to liquidate, since the gas required to liquidate them is more expensive than the bonus granted by the lender.
a dust factor that forbids loans with less than a threshold amount of collateral estimated to make the loan profitable.
This approach is problematic because it depends on unknown and unpredictable factors such as gas price and collateral value relative to the price of Ether. Major lenders have declined to implement dust thresholds and large-scale exploits are not known after years of operation.
Given the operational overhead and attack surface of implementing dust thresholds, we would shy away from them.
Auctions
So far we have been talking about instant liquidations that happen in a single transaction. A loan becomes unhealthy and becomes liquidated at that same moment for a predictable profit. The profit is also proportional to the size of the loan.
This means that large loans are more profitable for liquidators and riskier for borrowers.
Lenders don’t want to penalize their largest customers, and auctions are a tool that is sometimes used. When liquidating loans at an auction, the goal is to have liquidators compete and give the liquidation to the one that accepts to execute it at the smallest profit.
The initial implementation of a liquidation auction was possibly that of Sai, which employed an English auction in which liquidators escrowed funds to repay the debt while quoting the equivalent to decreasing liquidation bonuses for a set period. Liquidators escrowing the funds stops them from using flash loans, which makes this approach unusable nowadays.
. In a Dutch auction, the bonus paid to liquidators increases with time for the duration of the auction. If a liquidator waits, it has the possibility of earning a higher profit, but at the risk of another liquidator taking the opportunity. In a competitive environment, the result usually is that liquidators end the auction as soon as it crosses their profitability threshold.
If Dutch auctions are set so that the liquidation bonus offered at the start of the auction is above 0%, the effect can be that of an instant auction that then progressively grows the liquidation bonus in case no liquidators are found. This was the approach used by .Liquidation auctions are more complex than instant liquidations both for the lenders implementing them, and liquidators hoping to get a profit. The benefits of dynamic debt pricing must be weighed against the increased attack surface and liquidator bar of entry.
In any of the cases above, the additional complexity of implementing auction liquidations must be considered. In an instant liquidation, there is only one actor, the liquidator, and only one transaction, the liquidation. In an auction we will have an auctioneer and a liquidator that will each submit a transaction, often at different times, and have to be rewarded for it. There is a much-increased attack surface and a much more complicated incentive scheme that might not always be a reasonable trade-off for more efficient liquidation pricing.
Socializing Bad Debt
The loans that are unprofitable to liquidate are collectively referred to as bad debt. Sometimes they will be merged into a single value that is clear to work with, such as sin in MakerDAO.
Bad debt is dangerous because it is a sign that the lender won’t be able to honor all its commitments, be it returning the collateral it was entrusted with, or delivering profits to users that provided liquidity to the lender. Since this can be a scenario where the last users in abandoning the lender bear all the losses, it is often a race for the exit with a catastrophic outcome.
Often, this hole in the balance sheet is filled in by those who manage the lender from some treasury. However, it seems like a better idea to socialize bad debt immediately between either all or a subset of protocol users. This avoids self-reinforcing loops.
A Completely Different Approach
I recently read about a completely different approach by Instadapp to build . The code is not available yet but hints at integration with a Uniswap v3 style DEX, and their statements on liquidations allow us to infer a possible design.
In Uniswap v3 liquidity providers are equivalent to options traders over a price range. As the price in the trading pools travels across the range they provide liquidity for, their assets are traded. Let’s extend this idea into lending but with a twist.
When a borrower provides collateral, that collateral is used as liquidity in the associated DEX, in the pool that trades the collateral against the asset borrowed by the user. The debt becomes collateralized not by the collateral itself, but by the liquidity-providing position.
If the value of collateral relative to a borrowed asset drops, the price will travel through the associated liquidity positions in the DEX. The result is that the collateral is immediately traded for the borrowed asset at market price.
From the point of view of the lender, the loan is always collateralized. From the point of view of the user, the value of their collateral is dependent on the market and might get less collateral than they deposited if the market moves against them.
This approach requires deep integration with a functioning DEX in the style of Uniswap v3, but it has undeniable advantages:
There isn’t a dedicated liquidator role, the regular activity in the DEX executes the liquidations.
Users don’t pay any bonuses to liquidators, meaning their liquidation penalties are minimal.
Market liquidity isn’t a concern, as the borrowers provide the liquidity on opening the loan.
Conclusion
Liquidation mechanisms are crucial for lending on DeFi, but they are rarely understood. Users are interested in their ROI, not in the stability of a lender. No one thinks they are going to be liquidated, so they only care about how much was lost when they are.
On the other hand, designers of lenders should know that improperly designed liquidation mechanisms will be a fundamental problem. Even if a complete catastrophe is averted, unhappy liquidated users will make their voices heard.
The best liquidation mechanism is the one that reduces the risk of bad debt to the very minimum, at the minimum possible cost for the users. However, the liquidated users must pay a cost that will convince liquidators to liquidate them.
In this article, we have talked about solvency and healthiness. We have talked about the collateralization ratio, the liquidation bonus, the close factor, liquidation costs, and market limitations. We have discussed auctions as a path to achieve optimal liquidations. Finally, we also hinted at a market integration that might make the current liquidation mechanisms obsolete.
It is now your turn to take all this information and apply it. May you have happy liquidations.