Hifi Liquidator JS is an open-source liquidation service for the Hifi Finance protocol. It detects and liquidates bad debt, ensuring the solvency and stability of the Hifi protocol. This service can be run by anyone, and profits generated from liquidations will be sent to the wallet specified in the configuration.
The service monitors accounts for underwater vaults (where the debt is greater than the collateral) and liquidates them. It also handles liquidation of mature hTokens (hTokens that have reached their maturity date). The service is written in TypeScript and can be run using Docker, Docker Compose, or Yarn.
- NVM
- Yarn package manager
- Docker (optional)
- Clone the repository:
$ git clone https://github.com/hifi-finance/hifi-liquidator-js.git
$ cd hifi-liquidator-js
- Set the version of Node to use locally within the project:
$ nvm use
- Install the dependencies with Yarn:
$ yarn install
- Create a .env file and follow the
.env.example
file to add the requisite environment variables. This includes your wallet seed, selected account, selected liquidation strategy, API keys, and network information.
$ docker build ./ -t hififinance/hifi-liquidator-js
$ docker run --env-file .env hififinance/hifi-liquidator-js
$ docker-compose build
$ docker-compose up
$ kubectl create configmap hifi-liquidator-js-config-map --from-literal=network-name=homestead --from-literal=persistence-enabled=true --from-literal=selected-account=0 --from-literal=selected-strategy=uniswap-v3
$ kubectl create secret generic hifi-liquidator-js-secret --from-literal=alchemy-key="<ALCHEMY_KEY>" --from-literal=infura-key="<INFURA_KEY>" --from-literal=wallet-seed="<WALLET_SEED>"
$ kubectl apply -f persistentvolumeclaim.yaml
$ kubectl apply -f deployment.yaml
$ yarn start
The service is ran in production on via a Kubernetes cluster. Upgrades can be made as follows:
- After modifying the source code, update the version in package.json to
NEW_VERSION
. - Rebuild the Docker image and push the new version to Docker Hub:
$ docker build ./ -t us-west3-docker.pkg.dev/liquidation-bots/hifi/hifi-liquidator-js
$ docker tag us-west3-docker.pkg.dev/liquidation-bots/hifi/hifi-liquidator-js:latest us-west3-docker.pkg.dev/liquidation-bots/hifi/hifi-liquidator-js:<NEW_VERSION>
$ docker push us-west3-docker.pkg.dev/liquidation-bots/hifi/hifi-liquidator-js:<NEW_VERSION>
- Update the version of the Docker image in deployment.yaml to
NEW_VERSION
. - Push all changes to GitHub with the commit message:
build: upgrade package version to NEW_VERSION
. - Create a new GitHub release and include description of all changes made in the new version.
- Pull changes in the Kubernetes cluster and reset persistence and pods to run a fully updated instance:
$ git pull
$ kubectl apply -f persistentvolumeclaim.yaml
$ kubectl apply -f deployment.yaml
- Ensure that your wallet has enough funds to cover gas costs and subsidize collateral for liquidations. Additionally, make sure to grant all necessary token approvals for subsidization.
- Double-check that the
.env
file is set up correctly, as it contains essential information needed for the smooth operation of the service. - Currently, the service relies on new block information to initiate liquidations, which may put significant strain on API endpoints. Future enhancements could involve reacting to Chainlink price updates and implementing a cooldown period to reduce the load.
- To optimize API endpoint usage, consider enabling the service's data persistence feature by setting the
PERSISTENCE_ENABLED
environment variable.
- Ethereum Mainnet
- Polygon Mainnet
LGPL v3 © Mainframe Group Inc.