New Tool: `liquidityBot.py` (And a `nectarengine` Update!)
Hey everyone,
You know how sometimes you start working on one project, and it forces you to go back and fix up another? That’s exactly what happened this week. I started tinkering with a new script for managing liquidity on Hive-Engine, but in the process, I discovered some things in nectarengine
that weren't working quite right.
So, today's post is twofold: a new release for nectarengine
and the new tool that prompted it!
nectarengine
v0.0.9 is Live!
First things first, nectarengine
version 0.0.9 has been released and is now live on PyPI!
This update fixes a handful of issues I ran into with the liquidity pool and token object handling. As I was building the new bot, I realized some of the underlying functions needed to be more robust. Thanks to this new project, the library is now a little bit better for everyone.
You can grab the latest version from the usual places:
- PyPI:
pip install nectarengine --upgrade
- GitHub: https://github.com/TheCrazyGM/nectarengine
Introducing liquidityBot.py
Now, for the project that spurred those updates: a fun little script I'm calling liquidityBot.py
. This is an automated bot for Hive-Engine designed to help manage token swaps and liquidity provision.
The basic idea is to automate two key tasks:
- Conditional Swapping: The bot checks the market price of a token (the "target asset") against a base currency (like SWAP.HIVE). If the price is at or above a threshold you set, it will automatically sell a specified amount of your target asset.
- Automated LP Deposits: Here’s the interesting part. If the swap is successful, the bot can then take the proceeds (the SWAP.HIVE you just received) and automatically pair it with more of your target asset to deposit into the corresponding liquidity pool.
It’s a neat way to automate taking profits on a token while simultaneously deepening your position in its liquidity pool.
How to Use It
The script is run from the command line and configured with arguments. A typical dry-run might look something like this:
usage: liquidityBot.py [-h] [-t TARGET_ASSET] [-b BASE_CURRENCY] [-a AMOUNT] [-p THRESHOLD] [-acc ACCOUNT] [-d]
Automated token trading and LP management bot.
options:
-h, --help show this help message and exit
-t, --target-asset TARGET_ASSET
Symbol of the target asset to trade (default: PIZZA).
-b, --base-currency BASE_CURRENCY
Symbol of the base currency for trading (default: SWAP.HIVE).
-a, --amount AMOUNT Amount of the target asset to trade (default: 50).
-p, --threshold THRESHOLD
Price threshold in base currency to trigger sell (default: 0.047).
-acc, --account ACCOUNT
Override Hive account name from config.json (default: loaded from config.json)
-d, --dry-run Simulate transactions without broadcasting.
./liquidityBot.py --target-asset SIM --amount-to-swap 100 --price-threshold 0.00007 --dry-run
This would simulate selling 100 SIM tokens if the price is at least 0.00007 SWAP.HIVE, and then simulate depositing the proceeds back into the SWAP.HIVE:PIZZA liquidity pool. It requires a config.json
file in the same directory for your Hive account and active key.
This is still a work in progress, but if you want to check it out or tinker with it yourself, you can find the full script and a more detailed README
on GitHub.
- GitHub Repo: https://github.com/TheCrazyGM/liquiditybot
It's a perfect example of how building a specific-use tool can lead to discovering and strengthening the foundational libraries it depends on. Let me know what you think!
As always,
Michael Garcia a.k.a. TheCrazyGM
I'm always going deeper into the pools, so this is another potentially very useful tool! Congratulations on improving and refining nectarengine, that's excellent! I'm really intrigued by this tool, I just have to figure out how I could best make use if it. Thank you so much for all this incredible work that you do, and the very valuable contributions that you make so often! 😁 🙏 💚 ✨ 🤙
You keep creating these excellent tools for the community. Thank you for your hard work!