Slashtrade
A Telegram bot for Hyperliquid perps and Solana spot - size positions, track PnL, and get liquidation warnings without leaving the chat.
- A fleet of small Bun/Node services: a
grammYbot, an Elysia REST+WS backend, a Turnkey signer, a four-service notifier, anode-canvascard renderer, and a custom EVM indexer. - Server-side execution signs EIP-712 under Hyperliquid's
Exchangedomain with native builder-codes for fees; non-custodial via Turnkey sub-orgs (EVM + Solana under one key tree). - Notifier runs on shared Redis with BullMQ dedup (
SET NX) and a watchdog that reconnects the WebSocket and replays from a cutoff timestamp. - Indexer is a three-stage BullMQ pipeline with a
Piscinaworker pool and a hash-chain reorg detector that pauses, drains, and replays affected ranges.
Show long description Hide long description
Overview
Slashtrade is a Telegram trading bot for Hyperliquid perpetuals and Solana spot, built so users can size positions, track PnL, and get liquidation warnings without leaving the chat. It's a fleet of small Bun and Node services I built at Syntax Studios: a grammY bot, an Elysia REST + WebSocket backend, a Turnkey-backed signer, a multi-package Hyperliquid notifier, a node-canvas image service, and a custom EVM indexer.
Trade execution runs server-side. The bot sends a structured order to the backend, which constructs the action payload, deterministically encodes and hashes it, and signs EIP-712 typed data under Hyperliquid's Exchange domain. User-signed actions like withdrawals use a separate signing domain on the real chain, and every order embeds a builder hook so platform fees flow through Hyperliquid's native builder-codes flow rather than a wrapped fee contract.
Wallets are non-custodial through Turnkey sub-orgs. Each user gets a fresh sub-org provisioned with both EVM and Solana accounts under a single key tree, so the same custody root signs perp orders and Solana token transactions. The user's API key is encrypted at rest and signing requests are scoped per-request, so the backend never holds raw keys. Private-key export uses an ephemeral target key so the secret only materializes inside the user's chat session.
The notifier is a workspace of four cooperating services on a shared Redis. One worker owns the long-lived Hyperliquid WebSocket and emits trade events; another tails the all-mids stream into Redis for live prices; a risk service computes margin distance against a configured threshold and emits liquidation warnings; a delivery worker pushes the rendered cards back to the bot. BullMQ handles per-event dedup with SET NX guards and exponential backoff, and a watchdog reconnects the WebSocket and replays from a cutoff timestamp if the stream goes silent.
Cards are rendered by a separate Node service that clusters across CPUs and produces PNGs with node-canvas, with a Puppeteer fallback for D3-heavy chart endpoints. The bot itself stays lean: middleware ordered by chat id, in-memory sessions, multi-step trading flows registered as grammY conversations, and an O(1) callback router for inline keyboards.
The custom indexer is a Bun + Viem pipeline backing related services, with three BullMQ stages (fetch, process, persist), a Piscina worker pool for log decoding, batched Postgres writes via Drizzle, and a hash-chain reorg detector that walks parent hashes back up to a configured depth, pauses queues, drains them, and replays the affected range. Cron jobs handle housekeeping: refreshing perp metadata and SOL price, claiming limit-order fees, and unwrapping SOL.
Media
Demo 1
Demo 2
Demo 3
Demo 4
Demo 5