Ethereum Defi Liquidator

Ran an a custom Ethereum defi liquidation bot for dydx. For a quick summary of what that entails for those not familiar with space; dydx is an exchange that enables leveraged speculative positions against deposited collateral eg; deposit USDC and borrow ETH (deposited by other users) against it, if ETH goes up in value, you can sell the ETH, repay your USDC "loan" with interest and collect the profit. Obviously this doesn't always go the way traders want, and so when it goes the other way (ie the ETH falls in value in this given example, they ) that are about to go below their minimum collaterlization on the Etherum blockchain need to be liquidated, however every action on chain needs to be paid for and so they do not close themselves.

I stopped after a few months (Around Nov 19 - Feb 20) for a number of reasons listed below:

  • Infrastructure costs of running Ethereum node to scan mempool for oracle updates were very expensive for a personal project @ ~\$500/mo (had to inspect every tx in the mempool to find pending oracle updates which ate request quotas)
  • This was needed to submit transactions with various gas prices whilst the oracle update was pending to be sequenced in the same block, but just after the oracle transaction commited
  • Feast/famine nature of liquidations (only happen under big market moves usually, which usually meant no activity for several days)
  • Competition for this "free money" was already fierce, and a winner takes all environment, where it still costs money if you lose. Gas under severe market conditions becomes eye wateringly expensive, and even failed transactions (ie got beaten in the race) cost a lot.
  • Capital requirements to make it work were very high in order to actually buy out these underwater positions, (and had to have the capability to be able to hedge the exposure being taken on elsewhere/check that it wasn't already toxic/unprofitable (even with a 5% liquidator discount), as price oracle updates are largely based on centralized exchange price feeds, and to mitigate rogue price feeds from negatively impacting the price, the median value of several oracles is used to compute the price for the liquidation threshold, and so is much slower to update as you need a majority to have sent updated values reflecting the price elsewhere).
  • Realised that if it was lucrative enough for me to be doing it, miners (and/or the oracle providers) themselves would do it and be able to guarantee tx order (now very apparent with all the MEV antics in the dark forest)

Some screenshots from my tool I took at the time (as you can see by the prices) showing the top liquidator wallets, their profit/costs, accounts and the ability to sort by least collaterallized, and slack notifications of when Oracle updates occured (and any liquidations too, can see in the screenshot that it happens in the same block). I queried all the transactions calling the liquidate function call and cached the data to investigate, and also used it to toggle on when to scan the mempool for oracle updates to avoid inspecting every tx in the mempool when not close to any possible liquidations. All in all it was a fun, challenging and interesting project but wasn't something I could see becoming a long-term replacement for a full-time career.

Liquidator App Screenshot Liquidator App Screenshot Liquidator App Screenshot