I started building a Solana trading bot about six months ago because I was tired of the swap-through-browser workflow. Open Phantom, connect to Jupiter, set slippage, confirm, wait, check if it went through. For a single trade that's fine. When you're trying to catch a pump.fun token in the first 30 seconds, it's way too slow.
So I built a Telegram bot that lets me buy and sell any Solana token in one tap. Then I kept adding features. Now it's 4,500 lines of Node.js and I trade almost exclusively through it.
Here's how the whole thing works.
Architecture: No Frameworks, Just HTTP
The bot is pure Node.js. No telegraf, no grammY, no bot framework at all. I hit the Telegram Bot API directly with HTTPS requests.
Why? Frameworks add abstraction I didn't need. The Telegram Bot API is just a REST API. You poll for updates, you send messages. That's it. A framework would give me middleware patterns and plugin systems when all I wanted was to parse a callback query and execute a swap.
The main loop polls getUpdates and routes messages to handler functions. Simple if/else chain on the command text. Not elegant, but I know exactly what's happening at every step.
Swap Execution: Jupiter V6
Every trade routes through Jupiter's V6 API. The flow:
- User taps "Buy" and picks an amount
- Bot calls Jupiter
/quotewith the input mint, output mint, and amount - Bot calls Jupiter
/swapwith the quote to get a serialized transaction - Bot deserializes, signs with the user's keypair, and submits
Jupiter handles finding the best route across all Solana DEXs. I don't need to integrate Raydium, Orca, and Meteora separately — Jupiter does that.
One important detail: I set prioritizationFeeLamports: 'auto' on every swap. This lets Jupiter calculate the right priority fee based on current network conditions. Without this, transactions fail constantly during high-traffic periods.
MEV Protection with Jito
This was a big one. Without MEV protection, every swap sits in the public mempool where sandwich bots can front-run you. On Solana this is a real problem — you'll see worse execution prices because someone saw your transaction and traded ahead of you.
I integrated jito-js-rpc to submit transactions as Jito bundles. Instead of broadcasting to the regular RPC, the transaction goes to Jito's block engine. The transaction either lands in a block atomically or doesn't land at all. No mempool exposure.
The integration was straightforward. Replace the sendTransaction call with Jito's sendBundle and handle the different response format. The tradeoff is you pay a small Jito tip, but it's worth it — especially on larger trades where sandwich attacks would cost you more than the tip.
Pump.fun Integration
This is where things get interesting. Pump.fun tokens trade on a bonding curve before they "graduate" to Raydium. During that bonding curve phase, you can't buy them through Jupiter. You have to interact with the pump.fun program directly.
The bot handles this by:
- Checking if a token is still on the bonding curve (read byte 48 of the bonding curve account — if it's 0, not yet graduated)
- If pre-graduation: build a transaction that calls the pump.fun program directly, calculating price from
virtualTokenReservesandvirtualSolReserves - If post-graduation: route through Jupiter normally
I also built a poller that watches for new pump.fun token deployments every 60 seconds and a graduation checker every 120 seconds. Users can set up auto-sniping — the bot watches for new tokens and buys automatically based on criteria they set.
The Worker System
Beyond simple buy/sell, the bot runs 12 background workers that handle everything else:
- Limit orders: polls token prices and executes when targets are hit
- Copy trading: watches specified wallets and mirrors their trades
- DCA: executes recurring buys on a schedule
- Price alerts: notifies users when tokens hit price levels
- Auto take-profit: sells positions when profit targets are reached
- New token poller: watches pump.fun for fresh launches
Each worker runs on a different polling interval. Limit orders check every 3 poll cycles, copy trades every 2, DCA every 3. This keeps things balanced without hammering the RPC.
The copy trading implementation is probably the trickiest. You're polling a wallet's recent transactions, parsing what they bought or sold, then replaying that trade for your user. The latency between detecting their transaction and executing yours is the main challenge. Jito bundles help reduce this but it's never going to be instant.
Token Safety Scanner
After getting rugged a few too many times, I built a scanner that scores every token from 0 to 100. It checks:
- Mint authority status (renounced = good)
- Freeze authority status
- Top holder concentration
- LP lock status and duration
- Metadata anomalies
The score is weighted — mint authority being active is a bigger red flag than slightly concentrated holders. Users see this score before buying and the auto-sniper can be configured to only fire on tokens above a threshold.
It's not perfect. A token can score 90 and still go to zero for reasons the scanner can't detect (team just stops working on it, hype dies, etc.). But it catches the obvious scams — which is most of them.
Mini App
Recently shipped a Telegram Mini App that gives users a proper trading UI instead of just chat commands. Full token charts, one-tap trading buttons, portfolio overview. Telegram's Mini App platform is surprisingly capable for building lightweight trading interfaces.
What I'd Do Differently
If I started over, I'd probably split the workers into separate processes. Right now everything runs in one Node.js process, which means a crash in the DCA worker takes down copy trading too. Process isolation would make it more resilient.
I'd also use WebSockets for copy trading instead of polling. The latency improvement would be meaningful there even if it doesn't matter much for other features.
Try It
The bot is live and free to use. Trading fees are 1% per swap (0.5% for premium users at 0.1 SOL/month). You can pay for premium with Telegram Stars if you don't want to spend crypto on it.
There's also a referral program — you earn 50% of your referrals' trading fees for 14 days, then 30% permanently.
If you trade Solana and want something faster than a browser wallet: @solscanitbot on Telegram
Happy to answer questions about any of this in the comments.
Top comments (0)