The Economic Theory of Liquidators
Liquidators are often vilified actors in DeFi. The faceless bots sitting in the background ready to pounce on your account the second it becomes undercollateralized and steal the tokens you farmed with your own sweat, blood, and tears. Yet despite the pain we all feel after losing tokens due to a liquidation, liquidators play an essential role in securing the DeFi ecosystem and must make a non-trivial economic decision every time they choose to liquidate your hard-earned cash.
Who are Liquidators?
As DeFi has expanded numerous protocols such as Compound, MakerDAO, dYdX, Aave, Notional, etc. have been developed which allow for trustless collateralized lending. Through these protocols, a borrower may deposit collateral and use it to withdraw a separate asset paying an interest rate for the privilege.
This is the most primitive form of lending and requires no trust between the lender and the borrower. If the borrower were to renege on their side of the trade, the lender would be able to sell the borrower’s collateral on the open market and rebuy the borrowed asset leaving the lender flat. This is similar to how a home mortgage works in traditional finance where the bank feels comfortable lending you money to buy a house knowing that if you ever stopped making payments the bank could always foreclose on the house and recoup their investment.
Again in a similar fashion to how home mortgages operate, DeFi lenders will require collateral over the value of the loan, similar to a down payment in the home mortgage analogy. If the value of the borrowed asset drops, the lender has some cushion of excess collateral, meaning the lender is still able to retain their initial principal. If the lender allowed the price of the collateral to drop below the value of the borrowed asset before “foreclosing”, the anonymous borrower would simply walk away with their borrowed funds leaving the lender with a loss. To prevent lenders from losing money in this scenario, most protocols will hold a reserve of funds (usually funded through protocol fees) to repay lenders. If the loss was larger than the reserve held by the lending protocol it would lead to total system insolvency in which lenders are only paid back a portion of their funds. It is thus critical for these protocols to ensure insolvency doesn’t occur for the safety of the protocol and its lenders.
The ratio of collateral required over the amount borrowed is referred to as the collateralization coverage ratio (CCR) which can be calculated as:
Let’s say we have a lending protocol with a CCR of 1.5, meaning every $1.00 of borrowed funds requires $1.50 of collateral to be deposited. If you wanted to borrow $100 worth of DAI collateralized with ETH you’d have to deposit at least $150 worth of ETH. Let’s say now the price of ETH drops 10% and DAI stays constant. The value of your borrowed DAI is the same as before at $100, but now your ETH collateral is only worth $135. In this scenario, the protocol itself is still solvent, because the value of your collateral exceeds the value of your borrowed funds. You are however now in violation of the protocol’s CCR of 1.5 since the ratio of your collateral to borrowed funds is now only 1.35. There must be a mechanism to return your account to the proper ratio and restore the protective cushion to the protocol to protect against future price drops over the course of the loan.
This is where Liquidators come in. These lending protocols allow 3rd parties to step in and reverse a part of your loan, depositing your borrowed asset (in this scenario DAI), in exchange for a portion of your collateral (in this scenario ETH). As a reward for performing this important function protocols will provide price improvement to the liquidator using a parameter called the Liquidator Discount (LD).
Let's imagine in our previous scenario the lending protocol has set their LD at 5%, meaning the liquidator can rebuy the collateral at a 5% discount. Seeing that the account is under-collateralized a Liquidator can step in, buy up your collateral for a discount, and replenish part of your borrowed funds, and return your account to the desired CCR. This action is called liquidation and allows Liquidators to protect the protocol and earn themselves a nice discounted trade.
From the outside, this seems like a pretty juicy deal for the liquidators. Just write some code to automatically do liquidations when they become available, immediately reverse the liquidation on the open market, and rake in the money at the cost of innocent borrowers! And to be sure, the landscape for liquidators is incredibly competitive and lucrative (see Tom Schmidt’s excellent article about the competitive landscape of Liquidators). However, the economic decision for whether or not to liquidate is anything but trivial.
How does a Liquidator make money?
Naively, one may assume that a liquidator’s net profit from a liquidation, referred to as profit-and-loss (PnL), depends entirely on the liquidation size (Size) and the LD and could be calculated as such:
but this would ignore the fact that the liquidator has not ended up in the same position that they began. They started long DAI and ended long ETH. Since the liquidator only made this trade to take advantage of the liquidation discount and do some arbitrage on the open exchange, we’d expect the liquidator to go to the open market and reverse their position, selling their newly acquired ETH and rebuying DAI, ending their position flat and pocketing the profit. Doing this sale in open the market is not free and requires the liquidator to pay slippage which constitutes both the difference in execution price versus the quoted price and for our purposes can include the fixed fee that the exchange charges for doing a trade. Slippage in Decentralized Exchanges (DEXs) such as Uniswap can be pre-calculated by looking at the sizes of the liquidity pools. Slippage in Centralized Exchanges (CEXs) such as Coinbase is a little more complicated but can also be assumed to be a function of size, where liquidity, is measured as the depth of the order book rather than the liquidity pool. In either case, a liquidator will face some losses through slippage when hedging their position on an exchange.
A better approximation of the Liquidator’s realized PnL (rPnL) after exiting their position on the exchange and accounting for slippage can be calculated as:
Where Slippage is a function that aggregates the cost in slippage from exiting a position through either the central and/or decentralized exchange dependent on the trade size.
Already we can see some interesting results emerging. Using Gauntlet’s slippage model trained on historical slippage data and a simulated Liquidator we can visualize the rPnL of a liquidator liquidating at various sizes relative to Uniswap’s trading volume on January 2021 over various liquidation discounts:
As size increases relative to exchange trading volume we can see at first rPnL increasing as well. Eventually, due to the fact that slippage will increase faster than profits, the cost in slippage begins to outweigh the benefit from the LD and the liquidator’s PnL begins to slope downwards and even become negative at sufficient size, where the cost to exit the acquired position exceeds the benefit of the discount.
As might be expected a higher liquidation discount can support a larger liquidation size. Protocols that are small relative to the overall market may be able to maintain their liquidation dynamics with a low LD and save the borrowers some money but as they grow relative to the market a higher LD is necessary to compensate Liquidators sufficiently for them to intervene.
Taking this even further we can calculate the optimal liquidation size with respect to the trading volume at which a liquidator will be willing to liquidate at any given time. By approximating the derivative of a sampling of rPnL at various sizes we can calculate Marginal rPnL which shows the rate of change in rPnL as a liquidator chooses to liquidate more or less of a position.
By setting Marginal PnL to 0 (B) we find the size at which a liquidator would maximize rPnL (A), which is noticeably smaller than the size where the Liquidator would break even (C). In reality, this would be reflected as liquidators slowly liquidating an undercollateralized account overtime to avoid paying the slippage all at once by selling the entire account immediately on the open market. This would allow them to offset the risk of holding these assets onto the protocol rather than taking it on themselves.
Why can’t the Liquidator HODL?
This assumption that liquidators will immediately sell generally will hold for very large liquidations where liquidators make use of flash loans to liquidate and sell all at once within one transaction but may not hold for smaller transactions. In smaller liquidations, a liquidator with a large amount of assets can step in and temporarily hold the collateral asset while they slowly unspin their position rather than doing one large transaction and selling immediately.
These larger liquidators will have more advanced execution trading strategies such as Time-Weighted Average Price (TWAP) or Volume-Weighted Average Price (VWAP) where liquidators could sell off their position over time to minimize slippage costs. This type of liquidator would be able to increase their profits over the more simplistic liquidators by paying less in slippage.
While this strategy allows liquidators to minimize slippage, it opens liquidators up to the risk of their newly acquired position losing value before they can exit. This is an especially risky proposition as liquidations will only ever occur when the price of the collateral has already fallen meaning that for liquidation to occur in the first place we’re already talking about a volatile asset that just lost some amount of value.
We can account for this risk by instead of calculating rPnL, calculating expected PnL (ePnL) which represents the expected value of a liquidation after accounting for the time-weighted risk of holding a long position in the collateral asset.
We’ve introduced a few new elements here. We’ve added a Time variable which represents the time it takes for a liquidator to exit their position. Modified our slippage function to include time, where slippage decreases inverse to Time as the market is given more time to absorb the sold position. We’ve also added in a Risk function which increases relative to both Size and Time as the liquidator spends more time holding a volatile asset that may continue to fall in price.
The definition of the Slippage() and Risk() functions will depend significantly on the level of sophistication of the liquidator. A sophisticated Liquidator will be able to employ trading strategies that allow them to exit a position quickly while incurring the same amount of slippage as a less sophisticated liquidator (e.g. using automated trading strategies or OTC partnerships). A sufficiently advanced liquidator may also be taking on statistical hedging positions before the liquidation, allowing them to change the form of the Risk() function entirely.
Competitive Liquidators
Up until now, we’ve only considered a world in which one liquidator exists. If a liquidator chooses not to liquidate an account, they can leave it to liquidate at a later date. In reality, liquidations are competitive with many liquidators all fighting for the same liquidations.
There are two primary methods that lending protocols use for choosing which liquidator gets to liquidate an account:
- Liquidation Auctions
Some protocols. such as Maker and dYdX have an auction mechanism where liquidators can bid on the ability to liquidate under-collateralized accounts dynamically setting the liquidation discount. In this way, liquidation discount depends on market dynamics and can rise in response to periods where the risk/slippage in the market has increased and fall when risk/slippage is insignificant. When implemented correctly liquidation auctions can be very effective but add a great deal of complexity to the system. Unforeseen bugs in the liquidation mechanism during crash events, like those seen by Maker during the price crash on Black Thursday (March 12th, 2020) can be disastrous.
With a slight modification we can calculate our competitive PnL (cPnL) for liquidator auctions (la) to include the competition over liquidation discounts from other liquidators:
Here we’ve added the liquidator discount as a parameter to PnL where LD is the net effective liquidation amount that wins the auction for the liquidator. The method in which LD is calculated will depend on how the auction works but will include any fees/gas paid to win the auction.
2. First Come First Serve Liquidations (FCFS Liquidations)
Other protocols such as Aave, Compound, and Notional set a flat liquidation discount and allow liquidators to liquidate on a first come first serve basis. The first liquidator to call the liquidate() function in the protocol wins the liquidation and other liquidators will lose out on the gas they paid for the liquidation.
The primary way that we’re all familiar with speeding up transactions is by paying more gas, which is true for liquidators as well.
Here we see the USD gas price paid for transactions by percentile for December. The lowest percentiles fluctuate but stay within the $0.00–$0.0002 range (for context a Uniswap swap costs ~100k in gas, so for a $0.0002 gas price, a Uniswap swap would cost $20.00).
In the extremes we see the highest percentiles spiking at certain times on certain days, going orders of magnitude above what the average DeFi user is paying. These outliers are Liquidators (or other DeFi participants with high priority transactions) assigning huge amounts of gas to their transaction to maximize the odds that their liquidate() transaction goes through first. To some extent, we can model first-come-first-serve liquidations in the same way that we can model liquidation auctions, where agents bid using gas rather than auction mechanics. The largest difference here is that first-come-first-serve auctions have their liquidation discount capped, with the ability to effectively decrease as liquidators are forced to bid more gas to win the auction driving down the effective discount.
Since winning the liquidation is not guaranteed even if you pay the highest gas in FCFS Liquidations, liquidators must modify their PnL calculation to competitive PnL (cPnL) which can be derived as:
Here we’ve added in a Gas term. Where Gas is the amount the liquidator bids in gas to ensure the liquidation gets mined in the next block. Here we treat this as a deterministic process where the highest gas bidder gets the liquidation, although, in reality, this would come down to the expected chance of your transaction getting mined as well as other mempool shenanigans. For simplicity, here we can just assume that Gas is the expected amount necessary to spend either through gas or bribing miners, to get your liquidation through.
The Unified Model
In both the liquidation auction model and the FCFS Liquidation model PnL is dependent on market dynamics, either through the Gas required to win a liquidation or the LD set by auction. Instead of being a constant value, we can now think of LD as a function of the overall market.
This equation is the same as the original ePnL function except now takes the parameter Market which represents the overall market conditions such as price movements and volatility. As discussed Market parameterizes LD which is now a function that depends on the protocol and can either use the auction model or the FCFS Liquidation model. Slippage and Risk are also impacted by the market and must be updated. For example, in a market crash, liquidity may dry up and lead to increased slippage from exiting a large position as well as an increased risk due to higher volatility in the market.
Competitive Protocols
Over time we should expect market forces to push all protocols to ultimately have the same effective liquidation discount. In the long term liquidators choosing when/where to liquidate will cause liquidation discounts to equilibrate across protocols. Eventually, we can expect effective liquidation to be the same either through auction or variable gas prices.
Using the previously outlined models we can consider how the market will choose this liquidation discount. Here we consider a theoretical market where all protocols are available for immediate liquidation at the same size with the same assets. Because the sizes and assets are the same across all protocols we can model Liquidation Supply as simply cPnL(LD) and liquidation demand as the maximum amount that a protocol is willing to pay for a liquidation. We also assume that 50% of the protocols use liquidation auctions and 50% of protocols use the FCFS liquidation model.
Using these assumptions we can graph what the supply and demand dynamics of this market might look like:
The part of the Liquidation Demand curve that represents the auction liquidators’ demand (AB) is vertical because these protocols will accept any liquidation discount to sell their size.
The part of the Liquidation Demand curve that represents the demand from FCFS Liquidations protocols (BD) is downward sloping. This is because while all of these protocols may pay a lower effective liquidation discount due to gas prices they have a maximum discount set by governance meaning they will not allow liquidations at any discount. We assume that there are a variety of these protocols that have all set their liquidation discounts at different levels which leads to the downward sloping nature of this line where the protocols with the highest liquidation discounts will be liquidated before protocols with lower.
Where liquidation demand meets liquidation supply represents the market equilibrium (C) and is where the liquidation discount will be set for all of the liquidators. This is noticeably less than the amount many of these protocols would have been willing to pay through the auction mechanism (100%) or the maximum amount set by governance in the FCFS mechanism (BC). This equilibrium results in a large amount of producer surplus for the auction liquidation based protocols, who at worst would have been forced to pay all their collateral against a monopolistic liquidator ((0,1), F, E, (50, 1)). The equilibrium will also result in Dead Weight Loss (BCE) through gas fees as the FCFS protocols still pay out their governance set liquidator discount but liquidators lose their PnL through competing on gas prices, meaning that the producer surplus for the FCFS Liquidation protocols will be lost to miners. Liquidators will also receive producer surplus in the form of profits (FCG) which will primarily go to the most advanced liquidators who can minimize slippage and risk.
Protocols whose maximum liquidation discount is lower than this (CD) will not be liquidated since they are unwilling to sufficiently compensate liquidators. These protocols are at risk of insolvency if the price of their collateral continues to fall. In the medium term, these protocols will go insolvent and drop out of the market. In the long term, we expect these protocols to modify their liquidation discounts through governance until they are in line with the market eventually allowing 100% of protocols to remain solvent through liquidations.
The market liquidation discount will change depending on the efficiency of the liquidators as well as the number of liquidations occurring in the market which depends on the price of lent assets. Protocols not using auction mechanisms must constantly monitor this market and re-evaluate their liquidation discount to both ensure they are not throwing away collateral when the market rate is lower than theirs as well as ensure they’re not at risk of insolvency when the market rate is higher.
Liquidators at Gauntlet
Liquidations are complex! There’s no real “one size fits all” framework and there is intense competition among liquidators to improve their efficiency. The competition extends to the protocols themselves who need to become competitive in this economic landscape, both ensuring they don’t overpay liquidators or risk insolvency. To remain profitable in this world requires innovation and a deep understanding of the market.
Using our custom cryptocurrency simulation platform at Gauntlet we build out models to examine exactly these types of dynamics. We have custom liquidator agents that use the model outlined here to make liquidation decisions. These liquidators are then unleashed in simulation against the smart contracts that make up these protocols. We can then run experiments and observe how various market conditions and/or protocol parameterizations impact this interplay. We firmly believe that the design decisions these protocols make require quantitative consideration, deep thought, and sustained commitment to doing the work required to keep everything safe and functional. Liquidators are just one part of these design considerations.
(Special thanks to Tarun, Tony, and Victor for their help in proofreading this article)