Skip to content

Gearbox-protocol/liquidator-v2

Repository files navigation

Gearbox Liquidation node V2

Liquidation node designed for V2 version. Liquidador uses Gearbox Smart Router to find optimal ways how to sell all assets into underlying one.

Optimistic Liquidations

Liqudator has special "OPTIMITIC" mode which is designed to predict potential problem with liqudation. Liquidation is run in this mode on fork net only, after running script which set all liquidation threshold to zero, what makes all credit account liquidatable. Then liquidator makes network state snapshot and liquidation account one by one, revetrting to saved snapshot each time liquidation was done.

After testing all liquidation, it exists and save json file or send it on server via POST request.

This mode increases protocol security showing potential problems with liquidations before they happened.

How to configure

Use environment variables to configure bot

Environment Variables Configuration

Environment Variable Description
JSON_RPC_PROVIDERS RPC providers to use.
PRIVATE_KEY Private key used to send liquidation transactions.
SLIPPAGE Slippage value for pathfinder.
ADDRESS_PROVIDER By default uses address provider from @gearbox-protocol/sdk-gov. Use this option to override address provider.
HF_TRESHOLD Filter out all accounts with HF >= threshold during scan stage.
DEPLOY_AAVE_PARTIAL_LIQUIDATOR Deploy Aave partial liquidator contracts.
DEPLOY_GHO_PARTIAL_LIQUIDATOR Deploy Gho partial liquidator contracts.
AAVE_PARTIAL_LIQUIDATOR_ADDRESS Address of deployed partial liquidator contract for all credit managers except for GHO-based.
GHO_PARTIAL_LIQUIDATOR_ADDRESS Address of deployed partial liquidator contract for GHO credit managers.
DEPLOY_BATCH_LIQUIDATOR Deploy batch liquidator contracts.
BATCH_LIQUIDATOR_ADDRESS Address of deployed batch liquidator contract.
BATCH_SIZE Number of accounts to liquidate at once using batch liquidator.
MIN_BALANCE If balance drops before this value - we should send notification.
TELEGRAM_BOT_TOKEN Telegram bot token used to send notifications.
TELEGRAM_NOTIFICATIONS_CHANNEL Telegram channel where bot will post non-critical notifications.
TELEGRAM_ALERTS_CHANNEL Telegram channel where bot will post critical notifications.
RESTAKING_WORKAROUND Flag to enable less eager liquidations for LRT tokens.
SWAP_TO_ETH Use this mechanism to swap underlying token to ETH after the liquidation (abandoned feature).
ONE_INCH_API_KEY 1inch API key for swapper.
APP_NAME App name used in various messages to distinguish instances.
PORT Port to expose some vital signals and metrics.
DEBUG_ACCOUNTS Only check these accounts during local debug session.
DEBUG_MANAGERS Only check these credit managers during local debug session.
OPTIMISTIC Enable optimistic liquidations.
CAST_BIN Path to foundry/cast binary, so that we can create tree-like traces in case of errors. Used during optimistic liquidations.
OUT_DIR Directory to save JSON with optimistic liquidation results.
OUT_ENDPOINT REST endpoint to POST JSON with optimistic liquidation results.
OUT_HEADERS Headers for REST endpoint.
OUT_FILE_NAME Filename of JSON with optimistic liquidation results for S3 or dir output.
OUT_S3_BUCKET S3 bucket to upload JSON with optimistic liquidation results.
OUT_S3_PREFIX S3 bucket path prefix.

How to launch

The liquidator is distributed as docker image

For example, write your config into .env file and then run:

docker run --env-file .env ghcr.io/gearbox-protocol/liquidator-v2:latest

In normal mode

Set required env variables. Do not enable OPTIMISTIC_LIQUIDATIONS, OUT_* variables are not required.

In optimistic mode

Set required env variables. Set OPTIMISTIC_LIQUIDATIONS to true, configure OUT_* variables for your desired output format.

Important information for contributors

As a contributor to the Gearbox Protocol GitHub repository, your pull requests indicate acceptance of our Gearbox Contribution Agreement. This agreement outlines that you assign the Intellectual Property Rights of your contributions to the Gearbox Foundation. This helps safeguard the Gearbox protocol and ensure the accumulation of its intellectual property. Contributions become part of the repository and may be used for various purposes, including commercial. As recognition for your expertise and work, you receive the opportunity to participate in the protocol's development and the potential to see your work integrated within it. The full Gearbox Contribution Agreement is accessible within the repository for comprehensive understanding. [Let's innovate together!]