Coder Social home page Coder Social logo

andr11111 / liquidator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dydxprotocol/liquidator

0.0 0.0 0.0 418 KB

:robot::moneybag: Bot to automatically liquidate dYdX accounts

License: Apache License 2.0

Dockerfile 1.06% JavaScript 98.94%

liquidator's Introduction

dYdX Liquidator

Bot to automatically liquidate undercollateralized and expired dYdX accounts.

Usage

Docker

Requires a running docker engine.

docker run \
  -e LIQUIDATOR_ACCOUNT_OWNER=0x2c7536E3605D9C16a7a3D7b1898e529396a65c23 \
  -e LIQUIDATOR_ACCOUNT_OWNER_PRIVATE_KEY=0x4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318 \
  dydxprotocol/liquidator

Overview

This service will automatically liquidate undercollateralized and expired Accounts on the dYdX Solo Protocol. Liquidations on dYdX happen internally between Accounts, so no actual ERC20 token movements occur.

In order to use this liquidator bot, you will need a funded dYdX Account. If you use the default of LIQUIDATOR_ACCOUNT_NUMBER=0, you can fund your dYdX Account on trade.dydx.exchange/balances.

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.

Liquidation Mechanics

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
LIQUIDATOR_ACCOUNT_OWNER Ethereum address of the dYdX account owner that will do the liquidations
LIQUIDATOR_ACCOUNT_OWNER_PRIVATE_KEY Ethereum private key the dYdX account owner that will do the liquidations
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
LIQUIDATION_COLLATERAL_PREFERENCES List of preferences for which collateral markets to receive first when liquidating
LIQUIDATION_OWED_PREFERENCES List of preferences for which markets to liquidate first on an account when liquidating
LIQUIDATOR_ACCOUNT_NUMBER The dYdX account number to use for the liquidating account (0 will show up on trade.dydx.exchange/account)
MIN_LIQUIDATOR_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
ETHEREUM_NODE_URL The URL of the Ethereum node to use. We strongly recommend using your own Infura node since the default node can get overloaded during times of liquidation.
NETWORK_ID Ethereum Network ID
ACCOUNT_POLL_INTERVAL_MS How frequently to poll for liquidatable accounts
MARKET_POLL_INTERVAL_MS How frequently to poll for market updates
ENABLE_EXPIRATIONS true or false - whether to liquidate expired accounts (false by default)
EXPIRED_ACCOUNT_LIQUIDATION_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.
MIN_VALUE_LIQUIDATED The minimum value in USD to liquidate (1 USD = 1e36)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.