Achieving Fairness in Liquidations over B.Protocol

Yaron Velner
B.Protocol
Published in
5 min readAug 9, 2020

--

B.Protocol eliminates the gas wars between liquidators and shift value from miners to the users of the platform by giving a priority to selected liquidators who bid for a liquidation franchise. B.Protocol wish to encourage competition among liquidators when acquiring the franchise, but once the current set of liquidators is fixed, it wish to distribute the liquidations fairly among its liquidators. In particular, without giving an advantage to liquidators who use high gas prices.

In this post, we describe the fairness mechanism that is implemented in the first version of B.Protocol. We first describe the assumptions of the first version and the desired guarantees, then give high level description of the implementation, and finally give a walk-through over the reference code.

Assumptions and desired guarantees

Assumptions

  1. The first version of B.Protocol will be focused on the MakerDAO lending platform, and thus the first version of the fairness mechanism is tailored to MakerDAO price update process.
  2. In the first deployment of B.Protocol the number of liquidators is bounded by 5, and the first 5 liquidators will be handpicked according to their previous track record and contribution to the DeFi ecosystem.

Guarantees

  1. No gas competitions: liquidator does not get an advantage over other liquidators by using higher gas price. It should be note that, as usual, liquidator still compete with the rest of the Ethereum network on priority in the mining process, and at certain times could benefit from higher gas prices.
  2. Upgradability and lack of custody over liquidator funds: Upon launch, upgradability of the contract will be locked for a period of 6 months, other then to maintenance changes that will have to be approved (on-chain) by all liquidators. Hence, the B.Protocol team does not have custody over liquidator funds.

High level implementation

In order to achieve fairness, we decided that each CDP liquidation with over 1000 DAI debt will be shared among all 5 liquidators, provided that they have enough capital to provide a cushion, and smaller CDPs will be assigned to liquidators at random.

The liquidation part consists of two parts, the first is one is the topup, where liquidators provide a cushion, and the second one is the bite, where liquidators are repaying the user debt in return of a premium.

Topup

Recall that in B.Protocol, the liquidators provide a cushion, namely, repay part of the user debt, in order to achieve priority over MakerDAO keepers (i.e., the rest of the world).

Cushion size: In MakerDAO the price is updated every hour, and thanks to the OSM module the value of the update P’ is known an hour in advance. Hence, the size of a cushion will be the minimum amount that will keep user CDP safe for price update P’.

Cushion funds: Liquidators are requested to deposit before hand DAI for the cushion. If a liquidator will not have sufficient DAI balance when topup for a CDP is needed, then he will not be able to bite that CDP.

Topup: The topup(cdp) function is callable by any liquidator, and can be invoked only if the next price update is at most 30 minutes away, and the price update will make the CDP unsafe. If the CDP debt is under 1000 DAI, then a single liquidator is chosen at random, according to the hash of the CDP number and the current hour of the day. For bigger debt all liquidators who can provide their part in the needed cushion are chosen. Formally, if a cushion of x DAI is needed, then the set of liquidators is the maximal subset S, such that each liquidator has at least x/|S| DAI deposited.

Untop: the cushion that is used in the untop is returned to the liquidators either after the CDP was bite by them, or if the owner of the CDP performed an operation after the call to topup. To mitigate denial of service attack after malicious upgrade, the user operation will not invoke any call to the fairness protocol, but instead, will only return the cushion funds back. As a result, one of the liquidators should call the untop function in order to have these funds available again.

Bite

When a CDP (without its cushion) becomes unsafe according to the original MakerDAO system, then any liquidator that provided a cushion for it can bite its proportional share, up to a duration of one hour or until it becomes unsafe in the original MakerDAO original system (which is at least an hour in current MakerDAO configuration). E.g, if a CDP has a debt of 10,000 DAI, and 4 liquidators provided a cushion, then each liquidator can bite up to 2500 DAI. Moreover, each liquidator can bite it multiple times, up to a total amount of 2500 DAI. The premium on the liquidation is determined according to the MakerDAO current liquidation penalty (which is currently 13%), and the profit percentage liquidators committed to share with B.Protocol users. The DAI to ETH conversion rate is determined according to the MakerDAO trusted reference price.

In every bite, a proportional part of the cushion is given back to the liquidator who bites. For example, if the CDP debt is 1000 DAI, and 4 liquidators provided a cushion of 40 DAI (10 DAI each), then a bite of size 100 DAI, will consume 100 * 40/1000 = 4 DAI from the cushion. Which means the liquidator will need to provide only 96 DAI.

Code walk-through

The proposed mechanism is implemented as a pool contract, which allow the chosen liquidators (members) to deposit and withdraw DAI that resides in MakerDAO’s Vat.

The topup function assign CDPs to members who have sufficient balance for the cushion, and the untop and bite functions implement the corresponding logic from that was discussed in the previous section.

An high level overview of the process is depict below:

We note that this code is still in testing phase.

Conclusion

In this post, we described how chosen liquidators can interact with B.Protocol in a fair manner that eliminates gas wars between the members. We presented the current implementation, which is currently deployed on testnet, for potential liquidators to experiment and provide their feedback.

--

--