• This repository has been archived on 27/Sep/2022
  • Stars
    star
    468
  • Rank 93,767 (Top 2 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DEPRECATED [๐Ÿค–๐Ÿ’ฐ Bot to automatically liquidate dYdX accounts]

DEPRECATED [dYdX Liquidator]

Bot to automatically liquidate undercollateralized and expired dYdX accounts.

Usage

Docker

Requires a running docker engine.

docker run \
  -e WALLET_ADDRESS=0x2c7536E3605D9C16a7a3D7b1898e529396a65c23 \
  -e WALLET_PRIVATE_KEY=0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318 \
  -e ETHEREUM_NODE_URL=https://eth-mainnet.alchemyapi.io/v2/YOUR_ALCHEMY_KEY \
  -e SOLO_LIQUIDATIONS_ENABLED=true \
  -e SOLO_EXPIRATIONS_ENABLED=false \
  dydxprotocol/liquidator

Overview

This service will automatically liquidate undercollateralized and/or expired accounts on dYdX.

This bot works for Solo (Margin-Trading) accounts. Use the envvars SOLO_LIQUIDATIONS_ENABLED, SOLO_EXPIRATIONS_ENABLED to control what kind of liquidations to perform.

Liquidations on dYdX happen internally between Accounts, so you will need an already-funded dYdX Account to use this liquidator bot. If you use the default of SOLO_ACCOUNT_NUMBER=0, you can fund your dYdX Margin (Solo) Account on margin.dydx.exchange.

Successfully liquidating Accounts will modify your dYdX Account balances. You can liquidate assets you do not have in your Account provided you have another asset as collateral, which will just cause your dYdX Account Balance to go negative in that asset.

Solo Liquidations

Liquidations on Solo reward a 5% spread on top of the current oracle prices for the assets being liquidated and used as collateral. Example:

Undercollateralized Account:

+2 ETH
-350 DAI

Liquidator Account:

+100 ETH
-1000 DAI

Oracle Prices:

ETH Oracle Price: $200
DAI Oracle Price: $1

Fully liquidating this account would cause 350 DAI to be paid to zero out its balance, and would reward 350 DAI * ($1/DAI / $200/ETH) * 1.05 = 1.8375 ETH as payout. After the liquidation the account balances would be:

Undercollateralized Account:

+0.1625 ETH
0 DAI

Liquidator Account:

+101.8375 ETH
-1350 DAI

Configuration

Environment Variables

ENV Variable Description
WALLET_ADDRESS REQUIRED Ethereum address of the dYdX account owner that will do the liquidations
WALLET_PRIVATE_KEY REQUIRED Ethereum private key the dYdX account owner that will do the liquidations. Make sure that "0x" is at the start of it (MetaMask exports private keys without it).
NETWORK_ID Ethereum Network ID
ETHEREUM_NODE_URL REQUIRED The URL of the Ethereum node to use (e.g. an Alchemy or Infura endpoint)
LIQUIDATION_KEY_EXPIRATION_SEC Amount of time in seconds to wait before trying to liquidate the same account again
GAS_STATION_URL URL of the gas station API to use
GAS_PRICE_MULTIPLIER How much to multiply the fast gas price by when sending transactions
GAS_PRICE_UPDATE_FREQUENCY_SEC How frequently to update the gas price
SOLO_LIQUIDATIONS_ENABLED true or false - whether to liquidate solo accounts (true by default)
SOLO_EXPIRATIONS_ENABLED true or false - whether to liquidate expired accounts (false by default)
SOLO_COLLATERAL_PREFERENCES List of preferences for which collateral markets to receive first when liquidating
SOLO_OWED_PREFERENCES List of preferences for which markets to liquidate first on an account when liquidating
SOLO_ACCOUNT_NUMBER The dYdX account number to use for the liquidating account. If you're not sure what this is, use 0. This will show up on trade.dydx.exchange/account if you connect with the same wallet.
SOLO_MIN_ACCOUNT_COLLATERALIZATION The desired minimum collateralization of the liquidator account after completing a liquidation. Prevents the liquidator account from being at risk of being liquidated itself if the price of assets continues to move in some direction. Higher values are safer. e.g. 0.5 = 150% collateralization
SOLO_MIN_OVERHEAD_VALUE If you can liquidate less than this amount of value before hitting SOLO_MIN_ACCOUNT_COLLATERALIZATION, then don't liquidate. (1 USD = 1e36)
SOLO_EXPIRED_ACCOUNT_DELAY_SECONDS How long to wait before liquidating expired accounts. The spread for liquidating expired accounts ramps up linearly from 0% to 5% over 1 hour.
ACCOUNT_POLL_INTERVAL_MS How frequently to poll for liquidatable accounts
MARKET_POLL_INTERVAL_MS How frequently to poll for market updates

More Repositories

1

solo

dYdX V2 Margin Trading Protocol
TypeScript
418
star
2

dydx-v3-python

Python client for dYdX (API v3)
Python
306
star
3

v4-chain

dydx v4 protocol
Go
221
star
4

protocol_v1

[DEPRECATED] Solidity Smart Contracts for the dYdX V1 Margin Trading Protocol
JavaScript
200
star
5

perpetual

Ethereum Smart Contracts and TypeScript library used for the dYdX Perpetual Contracts
TypeScript
170
star
6

dydx-python

dYdX Python Client for Limit Orders
Python
108
star
7

v3-client

TypeScript client for dYdX (v3 API).
TypeScript
108
star
8

v4-web

TypeScript
74
star
9

exchange-wrappers

๐Ÿ’ฑ๐ŸฌCollection of exchange wrapper contracts used by the dYdX Protocol
Solidity
70
star
10

v4-clients

JavaScript
61
star
11

starkex-lib

Cryptographic functions for dYdX (v3 API)
TypeScript
25
star
12

dydx.js

[DEPRECATED] TypeScript library for interacting with the dYdX V1 protocol
TypeScript
22
star
13

starkex-eth

library for interacting and parsing logs for the starkware smart contracts
TypeScript
22
star
14

v4-abacus

JavaScript
14
star
15

v4-documentation

MDX
11
star
16

v4-infrastructure

HCL
8
star
17

walletdirect

Direct communication between dApps and Wallets with deep links
Swift
7
star
18

v4-testnets

Shell
4
star
19

starkex-peripheral

Contracts for interacting with StarkEx-contracts
TypeScript
4
star
20

node-service-base-dev

Shared dev dependencies, development configuration, and utilities for Node libraries and services.
JavaScript
4
star
21

leverage-intuition

Jupyter Notebook
3
star
22

v4-localization

TypeScript
2
star
23

grpc-stream-client

Example Client for dYdX Full Node gRPC Streams
Python
2
star
24

v4-native-android

JavaScript
2
star
25

go-systemCheck

Go
1
star
26

systemCheck

TypeScript
1
star
27

py-systemCheck

Python
1
star
28

v4-latency-scripts

Python scripts that measure the latency of the dYdX chain software
Python
1
star
29

cartera-ios

Swift
1
star
30

v4-native-ios

JavaScript
1
star