Illustrations by Lea Filipo

Liquidations in the Dark Forest: The B.Protocol and Gnosis Protocol approaches

By Yaron Velner and Chen Magen

Yaron Velner
B.Protocol
Published in
9 min readSep 23, 2020

--

Introduction

Over $6B in DeFi assets crucially relies on an adequate liquidation process for their security. The Dai ecosystem, lending platforms like Compound and Aave, synthetic asset platforms and margin trading platforms all rely on liquidations to remain solvent.

Whenever user debt is about to exceed its collateral, a liquidation process is triggered, in which a liquidator pays the user’s debt in return for a part of their collateral. All the major DeFi platforms currently outsource this service to the entire Ethereum community, by allowing every Ethereum account to participate in the liquidation process, and offer a discount of 3–8% on the liquidated collateral in order to incentivize the liquidators to participate.

This approach achieves fairness as all liquidators get equal chance. However it gives rise to two fundamental problems:

  1. Gas wars and MEV (miner-extractable value): in all of the main DeFi platforms, the fairness is typically obtained by a first come first serve approach, in which the liquidator that executes the liquidation first enjoys all of the discount (Compound, Aave, Dydx), or at least improves their position (MakerDAO). As the order of transactions is determined by the Ethereum miners, the liquidators compete via who will pay the highest gas price for his transaction. A recent academic study predicts that as the DeFi volumes will increase, the equivalent of the entire discount on the collateral will be spent on miners’ fees through gas price auctions.
  2. Lack of committed liquidators and available liquidity: as it is expected that most of the liquidation profits will eventually be extracted by the miners, and given the uncertainty that the first come first serve approach yields, traditional algo trading companies do not participate in DeFi liquidations, and DeFi algo traders who do participate are doing it on a best effort basis, as the uncertainty over the potential profit does not allow them to invest in preparing big inventories and advance hedging systems. (A perspective on the liquidators point of view can be found here). This concern is not only academic. The recent events of “Black Thursday” in March 2020, in which MakerDAO liquidators failed to secure over $8M of funds, showed that a lack of commitment would inevitably lead to default events. Moreover, the lack of commitment and on-chain feedback from the liquidator side makes it difficult to price the desired liquidation premium, leading to paying very high premiums in DeFi platforms, w.r.t centralized platforms.

In the remainder of this blog post, we survey two novel approaches for DeFi liquidations.

In the first approach, by B.Protocol, liquidators share their profits with the users in return to a priority in the liquidation process.

In the second approach, by Gnosis Protocol, a novel DEX design that mitigates front running and minimizes MEV, an alternative means is used to determine the right for the liquidation discount.

In the next two sections, we describe these approaches, and in the final section we explain how these two approaches could co-exist.

B.Protocol — a decentralized backstop liquidity protocol

B.Protocol approach is to shift the miners’ profits to the users, who in return give priority in the liquidation process to a set of committed liquidators. The advantages to this approach are twofold: 1. Lending platform users get higher yield; and 2. The platforms enjoy more committed liquidators, as their incentive to participate in liquidations is more deterministic.

Moreover, B.Protocol seamlessly integrates with existing platforms like MakerDAO and Compound, while giving their users exactly the same terms as the original platforms provide them. This is achieved by letting the users interact with the lending platforms via a dedicated smart contract interface. And B.Protocol liquidators get a priority in the liquidation process by providing a cushion to the user account when it is getting close to the liquidation price.

The below diagram shows how B.Protocol is built atop Compound. The protocol API to end-user is identical to Compound’s API, and the only difference is that the users are interacting with different addresses. Liquidators provide the cushion with a top-up operation, and a scoring engine updates the user rating whenever he performs an operation. The user rewards are kept in a “Jar” that is distributed according to the user rating.

We now describe how the cushion is being used to be prioritized over Compound’s original liquidators. Consider a scenario in which a user borrows 100 Dai when the ETH price is $200, and as the price goes down, the liquidity provider (LP) provides a cushion to the user debt. Finally, when the price of ETH hits the liquidation price, the LP liquidates the user on B.Protocol smart contracts and shares the profit with the Jar (which later will share it with the users of the platform).

This way B.Protocol gives better security guarantees to its underlying lending platforms, better yield to its users, and higher income to its liquidity providers. All without changing anything in the underlying lending platforms.

Gnosis Protocol — Advantages in execution of liquidation orders

We first describe how Gnosis Protocol (GP) works, and then we explain how it mitigates 1) gas wars and MEV (miner-extractable value), and 2) the unpredictable nature of participating in liquidations.

Gnosis Protocol: Batch Auctions and Ring Trades

Gnosis Protocol is a fully permissionless decentralized trading protocol (DEX), facilitating batch auctions that occur consecutively every five minutes. In each batch auction, trades are settled with uniform clearing prices.
The short time frame of the batches coupled with the uniform price clearing eliminates front running for traders and enables fair and equal opportunity for participation.

Additionally, Gnosis Protocol enables ring trades to maximize liquidity. Ring trades are order settlements which share liquidity across all trading pairs, rather than a single trading pair. Ring trades are achieved by aggregating all orders into a single order book, in practice allowing trades from and to any token, and consequently improving liquidity.

A few key properties of Gnosis Protocol’s auctions are imperative to understand:

  • The limit price of an order is the minimum a trader might receive, but according to supply and demand curves, they might receive a better price at settlement.
  • A trader can be sure their bid will be prioritized only according to its limit price and volume, and not by the gas price used for submission.

A brief explanation of front-running

It is well-documented that arbitrage bots are widely used on Ethereum nowadays. In order to include a transaction on the Ethereum blockchain, one needs to first broadcast the transaction to the mem-pool where it is visible for all to see and analyze. Arbitrage bots take advantage of this publicly available list of pending transactions to analyze it and find those transactions that represent profitable trades, liquidations or any other profitable action. Once a profitable transaction is found, front-running bots will try to pocket the profit to themselves. The transaction will be modified to include a different recipient address and then broadcast with a higher transaction fee. Ethereum miners usually order the transactions in a block according to their gas price (rational economic behaviour) which allows execution of the front runners’ transaction before the original transaction. This process can happen multiple times, and each time another bot will increase the gas price for the transaction, which explains the name “gas wars”. Miners are best positioned to front-run profitable transactions as they dictate transaction ordering in a block; thus the term Miner Extractable Value (MEV) was coined.

Mitigating gas wars and MEV

The only way to participate as a trader on Gnosis Protocol is to place a limit order, which will be considered in the next order submission window and thereafter for each 5 minute batch. All participants have the same opportunity to submit, update or remove their limit order in this initial 5 minute period regardless of the gas price other participants use. It’s important to note that orders submitted during this submission period and all open orders submitted before this submission period will be in the order book for the next batch.

Once the 5 minute order submission period is over for a given batch, no further orders will be considered for that batch settlement solution. Then, solvers will compete to submit the best settlement solution, which must comply with the following rules. Importantly, the solution must contain a single clearing price meaning all trades will settle with the same price regardless of their order.

Even if someone will try to “front-run” by submitting their order in the last moment of the 5 minute order submission period, they will never be able to get a better price than other participants in the same batch.

Mitigating the unpredictable nature of liquidations

As mentioned above, the first come first serve approach of most liquidation systems on Ethereum today, results in sophisticated gas wars for executing those liquidations. As a result, participants need to have high level of technical capabilities in two total separate areas instead of just one:

  1. Sourcing liquidity and hedging market volatility risks
  2. Optimizing gas price for transaction submission and dealing with the possible outcome of being outcompeted in transaction inclusion

Given that gas wars are mitigated on Gnosis Protocol, market makers now have the assurance that their bid will either 1) execute at or with a better price than the limit price or 2) will not execute at all. This enables them to just bid the best price they can and rest assured the only way to outcompete them is to outbid them — fair game.

Passive liquidity provision ensures any liquidation order sent to GP will meet at least a minimum amount of liquidity.

Passive liquidity provision is possible on GP through the custom market maker (CMM) strategy. Users of the CMM strategy are able to capture volatility by a similar means to LPs on AMMs like Uniswap through setting a spread. Moreover, CMM LPs will capture higher spreads if liquidations settle below market price, essentially profiting from there being liquidity of last resort for liquidations.

Liquidations on Gnosis Protocol

So, what would a liquidation sent to GP look like?

  • An order selling the collateral with a limit price set well below market price is submitted to GP.
    (If the sender trusts a price feed to a certain extent, they could set the limit price to x% below market price.)
  • The order immediately meets the liquidity already available in the GP order book.
  • Market makers that monitor the order book see the opportunity and start bidding — most likely based on prices in the most liquid markets minus a premium — knowing that they have the upside of maybe getting even a better price.
  • The 5 minute bidding window ends, and a snapshot of the orderbook is taken. This prevents frontrunning of bids.
  • A fair uniform clearing price is found, and all bids are cleared at this price.

To conclude, the liquidation benefits from the fair competition between market makers who are solely bidding for the auction itself rather than transaction fees.

Market makers benefit from a simpler bidding process and from being able to get even better prices than their original bid.

Combining the two approaches

B.Protocol offers the advantage that it can be built atop existing lending platforms without any change on their side, and design a mechanism to incentivize the users and liquidators to participate in. However it cannot scale to handle thousands of liquidators. Gnosis Protocol DEX’s advantage is a fair mechanism to reduce the MEV profits and that could scale to a larger number of liquidators. However, it would require changes in current lending platforms to operate.

A future direction for further research is how to combine these two approaches: namely, to plug Gnosis Protocol DEX in as one of the liquidators in B.Protocol or to put B.Protocol as one of the players that participate in liquidations over Gnosis Protocol DEX.

On a technical level, part of the liquidation will be placed as a limit order on Gnosis Protocol DEX. As the order offers a premium over the market price, the DEX will fairly fill it relying on the user’s liquidity.

More complex combinations, such as letting the fair DEX to absorb as much as possible, and having B.Protocol as a backstop to the cases where the market liquidity is not sufficient are also possible.

About B.Protocol:

B.Protocol makes lending platforms more secure by incentivizing liquidity providers (keepers) to commit on liquidation of under collateralized loans and shift the miners extracted profits back to the users of the platform. B.Protocol was founded by Yaron Velner, who was previously Kyber Network’s CTO and a co-designer of the WBTC protocol.

For more, please visit our website, twitter, discord and github.

About Gnosis:

Gnosis, a leading company in the flourishing Ethereum ecosystem, builds new market mechanisms for decentralized finance. Leveraging three interoperable product lines, Gnosis products allow users to securely create, trade, and store digital assets. Gnosis was founded in 2015 by Martin Köppelmann and Stefan George as part of ConsenSys, the globally leading Ethereum venture production studio. In April 2017, Gnosis raised funds and spun out of ConsenSys to become an independent company. Now more than 50 employees, Gnosis is based in Gibraltar, with team members globally and a main development hub in Berlin at the Full Node co-working space.

For more, please visit https://gnosis.io.

--

--