Liquidation bot Bounty

Hubble Exchange

  • Status: Active
  • Announced: Apr 12

Reward:

  • 3 winners (1 claimed) get ($5000 + 3 HSC) each sponsored by the Hubble DAO
  • Potentially, 6-7 figures if/when the liquidation bot works efficiently on the mainnet.
  • Given out when bot performs at least 1 liquidation on mainnet or makes a reasonable attempt to do so. Hubble DAO Policy Team reserves the right to choose the winners.

Introduction

In Hubble’s Protocol design, the exchange depends on liquidation bots to liquidate over-leveraged accounts i.e. when their collateral falls below their maintenance margin. Because Hubble is a decentralized exchange, anyone can create and run a liquidation bot on Hubble.

A liquidation penalty is imposed on accounts being liquidated. For carrying out the liquidation, bots receive a % from this penalty as incentive.

There are 3 kinds of liquidations in Hubble:

  1. Maker Liquidations

Liquidity providers in Hubble AMMs are called Makers. More details here. When the Maker’s suffer a high impermanent loss, they may get liquidated. Liquidation here simple means that their liquidity is forcefully removed from the AMM. This has a fixed payout of $20 per maker liquidated.

  1. Taker Liquidations

When an account reaches a state of leverage > 10x, they can be liquidated - i.e. their positions will be forcefully closed and they’ll be charged a liquidation penalty. Here, the liquidator will get 2.5% of the position size closed denominated in USD.

The above 2 liquidations don’t require any capital, flash loans, risk on part of the liquidator. There’s simply nothing to lose when you run a bot. Your bot just needs efficient monitoring of the trader’s position.

  1. Margin Account Liquidation

There’s also a 3rd type of liquidation that is more similar to an AAVE/Compound like liquidation but is outside the scope of this bounty. However, if the bounty hunter also implements this one, there’s definitely a big extra credit!

Note that liquidation payouts are subject to change based on the recommendation of the Hubble DAO Policy Team.

Technical Details

Contracts And ABIs

  • Get all traders (ClearingHouse.sol)
// Retrieve all PositionModified events, store all traders in a dbevent PositionModified(address indexed trader, uint indexed idx, int256 baseAsset, uint quoteAsset, int256 realizedPnl, uint256 timestamp);
  • Get All Makers (AMM.sol)
struct Maker {    uint vUSD;    uint vAsset;    uint dToken;    int pos; // position    int posAccumulator; // value of global.posAccumulator until which pos has been updated    int lastPremiumFraction;    int lastPremiumPerDtoken;    uint unbondTime;    uint unbondAmount;    uint ignition;}/*** @dev This is only emitted when maker funding related events are updated.* These fields are: ignition,dToken,lastPremiumFraction,pos,lastPremiumPerDtoken,posAccumulator*/event MakerPositionChanged(address indexed trader, Maker maker, uint timestamp);// Filter out all accounts that have ignition == 0 && vUSD == 0
  • Check if the account can be liquidated
function isAboveMaintenanceMargin(address trader) override external view returns(bool); 
  • Check whether the account is a maker
function isMaker(address trader) override public view returns(bool);
  • Perform Liquidations
function liquidateMaker(address maker) public;function liquidateTaker(address trader) public;function liquidate(address trader) external {    if (isMaker(trader)) {        liquidateMaker(trader);    } else {        liquidateTaker(trader);    }}

Notes

  • If the account is both a maker and taker, they need to be first liquidated as a maker. That may/may not get them outside the liquidation zone.
  • Note that checking isAboveMaintenanceMargin for all traders after every trade is a brute-force approach that might work, but the most efficient liquidation bot will actually have a much better strategy.

How to Participate

Do you think you can build one? Head over to Hubble discord and drop a message in the 🥷 protocol channel.