Liquidates undercollateralized Aloe II Borrower accounts using UniswapV3 flash swaps as a source of capital.
Aloe Labs is not responsible for any losses incurred by using this software. Use at your own risk. This is experimental software and is provided as-is, without warranty of any kind, express or implied.
Before running, be sure to create a .env
file in the app/
directory that contains the fields specified by the .env.template
.
You must have NodeJS and Typescript installed. Run yarn start
from the app/
directory.
You must have a running docker engine.
- Build the image with
docker build -t liquidator .
from within theapp/
directory. docker run --name <CONTAINER-NAME> -i -t liquidator:latest yarn start
to run the liquidator from a docker container.- NOTE: to stop, simply pressing Ctrl + C will not stop the liquidator container from running! You need to run
docker stop <CONTAINER-NAME>
.
Specifies a POLLING_INTERVAL
in index.ts
which generates a list of all the Borrowers on the protocol every POLLING_INTERVAL
seconds.
- Checks if a borrower is insolvent by estimating the gas when calling the Liquidator's
liquidate
method on the borrower.- If the gas estimate returns a value greater than 0, the borrower is deemed insolvent and is sent to the TXManager to be liquidated.
- If gas estimate returns an error, the borrower is deemed solvent.
- TXManager attempts liquidation. If it fails, retries with a gas cost that is 10% higher than the previous amount.
This implementation connects to an Alchemy node using a websocket connection. If you'd like to use a different node provider, change the following line:
const OPTIMISM_ALCHEMY_URL = `wss://opt-mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_API_KEY!}`;
in the app/index.ts
file to:
const NODE_PROVIDER_URL = <NODE-PROVIDER-URL>;
and the following line:
let provider = new Web3.providers.WebsocketProvider(OPTIMISM_ALCHEMY_URL, {...});
to
let provider = new Web3.providers.WebsocketProvider(NODE_PROVIDER_URL, {...});
Note: the change shown above assumes that the NODE-PROVIDER-URL
begins with a wss
because we use a WebsocketProvider
. If you'd like to connect to your node provider using a different protocol (eg. IPC
or http
) you'll have to change new Web3.providers.WebsocketProvider
to the corresponding protocol.
Name | Description |
---|---|
WALLET_ADDRESS |
Required. Address which receives the liquidation reward on success. |
WALLET_PRIVATE_KEY |
Required. Used by the TXManager to create the Account object that sends and signs liquidation transactions. |
ALCHEMY_API_KEY |
Required Used to initialize the Web3 client that gets information from the blockchain and sends transactions. This implementation uses Alchemy as the node provider, if you want to use a different node provider, see sub section Node Provider . |
FACTORY_ADDRESS |
Required. Address of the Aloe II Factory that is responsible for creating borrowers. |
CREATE_ACCOUNT_TOPIC_ID |
Required. Specifies the topic that provides the address of the newly created borrower. |
LIQUIDATOR_ADDRESS |
Required. Address of the liquidator contract on-chain. See app/addresses.md for details. |
SLACK_WEBHOOK0 , SLACK_WEBHOOK1 , SLACK_WEBHOOK2 |
Required, if using Slack to receive messages. Webhooks are of the form https://hooks.slack.com/services/<SLACK_WEBHOOK0>/<SLACK_WEBHOOK1>/<SLACK_WEBHOOK2> . We pass in the parts of the webhook this way because of the way .env deals with links. If either SLACK_WEBHOOK0 , SLACK_WEBHOOK1 , or SLACK_WEBHOOK2 is not provided, then we log an error message to the console and exit with code 1. |