- Flexible buy and sell strategies
- Both bonding curve + pump swap amm
- Supports mayhem mode, new token2022 program and legacy metaplex program
- 1-2 slots tx landing
I made this for myself and used it a lot. Therefore:
- parts of the code may be ugly: I needed something fast and didn't come back to it later.
- parts of the code simply doesn't work anymore: they became obsolete. Details below. I left them in case someone may be interested in. You can fix something by yourself or dm me, and we can take a look.
- there's no setup guides or anything. This is basic python setup, you just have to have some basic experience. Or ask AI.
- use at your own risk and responsibility
What i used mostly — parametrized trading strategies. Usually sniping or copy trade
Quick example of sniping and copytrade strategies:
[
StrategyFactory(
code='snipe_example',
buy_condition=lambda trader: trader.token.symbol == "EXAMPLE",
sell_condition=lambda trader: trader.current_pnl() > 1.5, # sell on +50% pnl
buy_amount=0.5, # SOL
slippage=30,
priority_fee=0.001, # SOL
tip=0.001, # SOL
max_buys=1 # will stop buy after first buy
),
StrategyFactory(
code='copytrade_example',
buy_condition=lambda
trader: trader.token.latest_swap.user == 'target_wallet' and trader.token.latest_swap.is_buy,
sell_condition=lambda trader: dont, # no selling
buy_amount=0.1,
slippage=20,
priority_fee=0.01,
tip=0.01,
max_buys=100
)
]And you can have any number of such strategies running concurrently. There's a lot of different parameters you can use, so i made some examples
Familiarize yourself with Token and Trader classes to better understand what data it contains.
On buy bot will send message to your provided TG. (You will need to create own TG bot for this and paste its api-key. And your chat id where bot should send message). If you don't want it - just comment this in code.
StrategyFactory has different fields, they should be self-explanatory, but here's some info:
code— used only for your convenience. this code will be used in TG message, so you can quickly understand what you just boughtmax_buys— how many different coins will be bought for current strategy. E.g. you can set max_buys=100 and specify dev - and you will buy next 100 coins from this dev.load_metadata— it will load ipfs url with metadata. sometimes you will want it but keep in mind, this is URL request, and it will take some time (0.1 to 1 sec usually, but can freeze for 20-30 sec because of connection issues)first_dev_coin— will buy only if it's first dev's coin.⚠️ devs is being tracked in memory, so each reload will wipe all data about previous dev creations. Essentially this means if dev hasn't yet created anything since last reload. Ofc i know it's not ideal, but it was sufficient for me
I've got around 50% of buys in next slot. Around 75% in slot 2. And this is just over wifi, but you need Helius developer RPC, this is crucial. I've also run it on server, had Solana Vibe Station VPS + their RPC node and it was faster, but never in same slot. If you want same slot landing, I believe you will need gRPC Geyser stream + shotgun strategy: send multiple tx to different rpc's and set proper priority fees and tips. But it requires code changes. So you won't be faster than specialized sniper bots, but it's not the point: you can be smarter and have more flexibility over strategies.
You need to add data to config in order to things work.
Rename env example to .env.local and fill fields
HTTPS_RPC_ENDPOINT use helius developer rpc for 1-2 slot
WSS_RPC_ENDPOINT same from helius
PRIVATE_KEY your private key
And you will need TELEGRAM_API_KEY and TELEGRAM_CHAT_ID.
Google how to get it for telegram or upd some code if you don't need notifications
- bot can buy the same coin only once and once sell everything. You can provide small updates to change it.
- it was designed to be lightweight and fast - it stores everything in temp memory therefore bot is able to buy only coins that created after latest launch
So it all was incremental and i've tried different ideas, some of them become useless. Some of them i left in the code, maybe it will be interesting for someone.
I was saving all transactions in local postgres database and run backtests on this past data using the very same strategy that will be used for live trading. It tries to simulate properly via adding tx delay and fees.
Usually it was some default metrics like BB, RSI, MA, etc.
I've tried to detect this non-organic charts we all know. As well as bundlers, volume bots, etc.
Essentially backtests + metrics + anomalies were working together: i was able to tweak different buy conditions (like BB width <30% + RSI < 30) and run quick backtests. Nothing supersucessfull, but you can try it yourself (you will need to set up database and refactor strategy and maybe refactor metrics).
Made some success making ML model, but it was not profitable. But you can easily develop yours and use it in strategies.