feat: Telegram bot for deploying on-chain trading agents#17
Open
feat: Telegram bot for deploying on-chain trading agents#17
Conversation
Telegram-native interface for deploying, monitoring, and controlling autonomous trading agents on Hyperliquid — like wallet bots but for agents. New module: tg_bot/ (12 files) - /start: wallet create/import with encrypted keystore - /deploy: strategy selection keyboard (18 strategies), instrument picker, risk presets (conservative/default/aggressive), mainnet double-confirm - /status /pause /resume /stop /balance: agent lifecycle control - /apex: multi-strategy APEX orchestration mode - NotifyingEngine: TradingEngine subclass pushing fills, PnL, risk alerts to Telegram via async queue with throttling - EngineBridge: thread-safe bridge (async bot <-> blocking engine thread) CLI: `hl telegram start [--mainnet] [--dry-run]` Deploy: RUN_MODE=telegram in Railway, Dockerfile installs telegram dep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Telegram-native interface for deploying, monitoring, and controlling autonomous trading agents on Hyperliquid — like the Telegram wallet bot craze (Maestro, Banana Gun) but for agents instead of swaps.
tg_bot/(12 files, 1787 lines) — full Telegram bot with conversation flows, inline keyboards, and real-time notificationsTradingEngine, strategies, keystore, and HL adapterUser Flow
/start→ create or import wallet (encrypted keystore, private key message auto-deleted)/deploy→ inline keyboard: pick from 18 strategies → instrument → risk preset (conservative/default/aggressive) → confirm/status/pause/resume/stop/balance→ full lifecycle control/apex→ APEX multi-strategy orchestration modeArchitecture
NotifyingEnginesubclassesTradingEngine, pushes events toasyncio.QueueEngineBridgemanages engine thread lifecycle from async Telegram contextNotifierreads queue, sends throttled messages (fills always-send, PnL every 5min)/start, mainnet double-confirmation gateUsage
Railway: set
RUN_MODE=telegram+TELEGRAM_BOT_TOKENin env vars.Files Changed
tg_bot/— bot, auth, config, engine bridge, notifier, formatters, handlers (start, strategy, control, apex)cli/commands/telegram_cmd.py—hl telegram startCLI commandcli/main.py— register telegram subcommand (2 lines)pyproject.toml— addtelegramoptional dep group, includetg_bot*packagescripts/entrypoint.py— addtelegrammode to Railway entrypointDockerfile— install telegram depTest plan
pip install -e ".[telegram]"succeedshl telegram startexits with clear error ifTELEGRAM_BOT_TOKENnot set/startin Telegram → wallet created/deploy→ strategy keyboard → instrument → preset → confirm → agent runs/statusshows live position + PnL/pause→/resumeworks/stop→ graceful shutdown with summary card/apexstarts APEX orchestrator,/apex_stopstops itpytest tests/ -x -q)RUN_MODE=telegramboots correctly