Keeper Bots in the Drift Protocol keep the protocol operational by performing automated actions as autonomous off-chain agents. Keepers are rewarded depending on the duties that they perform.
The various types of keeper bots are:
Tutorial: Order Matching Bot
Tutorial: Order Trigger Bot
Tutorial: Liquidation Bot
Note: all bots require some amount of SOL for user account rent and to pay transaction fees.
The reference implementation for all Keeper bots mentioned in these docs is available here.
First clone the keeper-bots-v2 repo (make sure to check out the correct branch for the cluster you are targetting)
Prepare the required environment variables by copying over .env.example, modify .env with your preferred values
Required Environment Variables
KEEPER_PRIVATE_KEY: the private key of the account to use for signing transactions. This account is the signing of authority of all accounts used by this bot. The value can be a number array (as in the example) or a path to a keypair.json file as generated by solana-keygen ENDPOINT: the JSON-RPC endpoint to use ENV: devnet
The signing account needs to have a User account before they are able to interact with the DriftClient program. We've included a --init-user flag on the Keeper Bot script to help with initializing new users.
❗Only required if you are trading or your bot needs to maintain open positions (JIT makers and certain liquidators)
Trading, as well as some Keeper functions (Liquidators and JIT makers), require the account to maintain open positions, and so those accounts must hold collateral. The Keeper Bot script includes a --force-deposit flag to help with depositing collateral.