This repo has two main branches:
master
: bleeding edge, may be unstable, currently running on thedevnet
clustermainnet-beta
: stable, currently running on themainnet-beta
cluster
A .yaml
file can be used to configure the bot setup now. See config.example.yaml
for a commented example.
Then you can run the bot by loading the config file:
yarn run dev --config-file=example.config.yaml
Here is a table defining the various fields and their usage/defaults:
Field | Type | Description | Default |
---|---|---|---|
global | object | global configs to apply to all running bots | - |
global.endpoint | string | RPC endpoint to use | - |
global.wsEndpoint | string | (optional) Websocket endpoint to use | derived from global.endpoint |
global.keeperPrivateKey | string | (optional) The private key to use to pay/sign transactions | KEEPER_PRIVATE_KEY environment variable |
global.initUser | bool | Set true to init a fresh userAccount |
false |
global.websocket | bool | Set true to run the selected bots in websocket mode if compatible |
false |
global.runOnce | bool | Set true to run only one iteration of the selected bots |
false |
global.debug | bool | Set true to enable debug logging |
false |
global.subaccounts | list | (optional) Which subaccount IDs to load | 0 |
enabledBots | list | list of bots to enable, matching key must be present under botConfigs |
- |
botConfigs | object | configs for associated bots | - |
botConfigs.<bot_type> | object | config for a specific <bot_type> | - |
Run from repo root to install npm dependencies:
yarn
A ClearingHouseUser
must be created before interacting with the ClearingHouse
program.
yarn run dev --init-user
Alternatively, you can put the private key into a browser wallet and use the UI at https://app.drift.trade to initialize the user.
Some bots (i.e. trading, liquidator and JIT makers) require collateral in order to keep positions open, a helper function is included to help with depositing collateral. A user must be initialized first before collateral may be deposited.
# deposit 10,000 USDC
yarn run dev --force-deposit 10000
Alternatively, you can put the private key into a browser wallet and use the UI at https://app.drift.trade to deposit collateral.
After creating your config.yaml
file as above, run with:
yarn run dev --config-file=config.yaml
By default, some Prometheus metrics are exposed on localhost:9464/metrics
.
Include filler
and/or spotFiller
under .enabledBots
in config.yaml
Read the docs: https://docs.drift.trade/keepers-and-decentralised-orderbook
Fills (matches) crossing orders on the exchange for a small cut of the taker fees. Fillers maintain a copy of the DLOB to look for orders that cross.
Read the docs: https://docs.drift.trade/liquidators
This liquidator implementation includes an option to useJupiter
to derisk (sell) spot assets into USDC. The derisk loop will use
the more favorable of Drift spot or Jupiter before executing. Set useJupiter
under the liquidator config to enable this behavior
(see below).
You may also set disableAutoDerisking
to true
, to disable the derisking loop. You may want to do this as part of a larger strategy
where you are ok with taking on risk at a favorable to market price (liquidation fee applied).
By default the liquidator will attempt to liqudate (inherit the risk of)
endangered positions in all markets. Set botConfigs.liquidator.perpMarketIndicies
and/or botConfigs.liquidator.spotMarketIndicies
in the config file to restrict which markets you want to liquidate. The
account specified in global.subaccounts
will be used as the active
account.
perpSubaccountConfig
and spotSubaccountConfig
can be used instead
of perpMarketIndicies
and spotMarketIndicies
to specify a mapping
from subaccount to list of market indicies. The value of these 2 fields
are json strings:
botConfigs:
...
liquidator:
...
useJupiter: true
perpSubAccountConfig:
0:
- 0
- 1
- 2
1:
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
spotSubAccountConfig:
0:
- 0
- 1
- 2
Means the liquidator will liquidate perp markets 0-2 using subaccount 0, perp markets 3-12 using subaccount 1, and spot markets 0-2 using subaccount 0. It will also use jupiter to derisk spot assets into USDC.