81 lines
2.8 KiB
Plaintext
81 lines
2.8 KiB
Plaintext
# Keeper Bots
|
|
|
|
Keeper bots keep Drift operational by performing automated actions as off-chain agents. Keepers are rewarded depending on the duties they perform.
|
|
|
|
| Bot Type | Difficulty | Capital Required | Rewards | Link |
|
|
| :------------ | :--------- | :--------------- | :------ | --------------------------------------------------------------------------------- |
|
|
| Matching Bot | Basic | No | TBD | [Tutorial: Order Matching Bot](/developers/trading-automation/keeper-bots/order-matching-bot) |
|
|
| Order Trigger | Basic | No | TBD | [Tutorial: Order Trigger Bot](/developers/trading-automation/keeper-bots/order-trigger-bot) |
|
|
| Liquidator | Advanced | Yes | TBD | [Tutorial: Liquidation Bot](/developers/trading-automation/keeper-bots/liquidation-bot) |
|
|
| JIT Maker Bot | Advanced | Yes | TBD | [Tutorial: JIT Maker Bot](/developers/trading-automation/keeper-bots/jit-maker-bot) |
|
|
|
|
_Note: all bots require some SOL for rent and transaction fees._
|
|
|
|
Reference implementations live in [keeper-bots-v2](https://github.com/drift-labs/keeper-bots-v2).
|
|
|
|
<Steps>
|
|
### Clone the repo and choose a branch
|
|
|
|
Pick a branch that matches your cluster. Note: in this repo, `master` tracks **devnet** (not mainnet-beta).
|
|
|
|
| Branch Name | Cluster |
|
|
| ------------ | ------------ |
|
|
| master | devnet |
|
|
| mainnet-beta | mainnet-beta |
|
|
|
|
```shell copy
|
|
git clone https://github.com/drift-labs/keeper-bots-v2 -b mainnet-beta
|
|
```
|
|
|
|
### Configure environment + YAML config
|
|
|
|
Copy the env template and set required values:
|
|
|
|
```shell copy
|
|
cp .env.example .env
|
|
```
|
|
|
|
Required env vars:
|
|
|
|
- `KEEPER_PRIVATE_KEY`: keypair array or path to `keypair.json`
|
|
- `ENDPOINT`: RPC endpoint
|
|
- `ENV`: `devnet` or `mainnet-beta`
|
|
|
|
The repo uses a YAML config for bot selection and per-bot settings. Start from `example.config.yaml` and set:
|
|
|
|
- `global.endpoint`
|
|
- `global.keeperPrivateKey` (or env var)
|
|
- `enabledBots` + `botConfigs`
|
|
|
|
### Initialize a Drift user (if needed)
|
|
|
|
Bots that place orders or manage positions require a Drift user account. The repo provides a helper flag:
|
|
|
|
```shell copy
|
|
yarn run dev --init-user
|
|
```
|
|
|
|
```typescript copy
|
|
if (!(await driftClient.getUser().exists())) {
|
|
logger.info(`Creating DriftClient for ${wallet.publicKey}`);
|
|
const [txSig] = await driftClient.initializeUserAccount();
|
|
logger.info(`Initialized user account in transaction: ${txSig}`);
|
|
}
|
|
```
|
|
|
|
### Deposit collateral (if needed)
|
|
|
|
Required for liquidators and JIT makers that keep open positions:
|
|
|
|
```shell copy
|
|
# deposit 10,000 USDC from account
|
|
yarn run dev --force-deposit 10000
|
|
```
|
|
|
|
### Run the bots
|
|
|
|
```shell copy
|
|
yarn run dev --config-file=example.config.yaml
|
|
```
|
|
</Steps>
|