Market maker keeper for the Kuest CLOB.
This software is experimental and in active development. Use at your own risk.
The keeper is a market maker for CLOB markets. Places and cancels orders to keep open orders near the midpoint price using the Bands strategy.
- Python 3.10
-
Run
./install.shto set up the virtual environment and install depedencies. -
Create a
.envfile. See.env.example. -
Modify the entries in
config.env. -
Modify
config/market-maker.jsonif desired.
If you are running on Polygon Amoy and run out of test USDC, you can request more by typing /airdrop in the Kuest Discord: https://discord.gg/kuest
- Start the keeper with
./run-local.sh.
- To start the keeper with docker, run
docker compose up.
The config.env file defines 3 environment variables:
CONDITION_ID, the condition id of the market in hex string format.STRATEGY, the strategy to use: "Bands" (case insensitive)CONFIG, the path to the strategy config file (defaults toconfig/market-maker.json).
The strategy config file contains the band definitions plus runtime settings like
amountJitterPct, minOrderSize, minBalanceToOperate, split controls, and shutdown
options like shutdownCancelAll and shutdownMergePositions.
Key settings:
amountJitterPct: randomizes band amounts by +/- this percentage.minOrderSize: minimum order size; orders smaller than this are skipped.minBalanceToOperate: total balance threshold; below this the bot aborts the cycle.splitMinBalance: minimum balance per token (A/B); below this the bot may split collateral.splitCooldownSeconds: minimum time between split attempts.splitTargetCollateral: optional cap for split amount; if 0, derives a target from band max amounts.shutdownCancelAll: cancel all orders on shutdown when true.shutdownMergePositions: merge positions on shutdown when true.
- Bands
- AMM strategy is not supported; only Bands is available.
The app can automatically split collateral into conditional tokens when token balances
are low. A split is attempted when either token A or B is below splitMinBalance,
collateral is available, and the cooldown has elapsed. The split amount is the smaller of:
splitTargetCollateral(if set), or- sum of band
maxAmountvalues, or - a small fallback value.
On shutdown, the app can merge token A/B back into collateral when
shutdownMergePositions is enabled.
Every sync_interval (the default is 30s), the strategies do the following:
- Fetch the current midpoint price from the CLOB
- Compute expected orders.
- Compare expected orders to open orders.
- Compute open orders to cancel and new orders to place to achieve or approximate the expected orders.
- Cancel orders.
- Place new orders.
When the app receives a SIGTERM, all orders are cancelled and positions are merged by
default. You can disable either behavior in config/market-maker.json.