Research Report & Architecture Design for Hyperliquid-focused Trading Agent
Pigeon is a multi-agent AI trading platform that positions itself as "the first AI wallet that can talk, code, research, and trade." It's essentially a conversational interface to multiple financial marketsβcrypto, stocks, forex, perpetuals, and prediction markets.
Pigeon uses a multi-agent architecture where different specialized agents handle different tasks:
| Category | Integration | Purpose |
|---|---|---|
| DEX (EVM) | KyberSwap | Aggregated swaps on Ethereum, Base, Arbitrum, etc. |
| DEX (Solana) | Jupiter | Solana swaps + limit orders |
| DEX (TON) | DeDust | TON blockchain swaps |
| Perpetuals | Hyperliquid | Perps trading with advanced orders |
| Traditional | Ostium | Stocks, forex, commodities (synthetic) |
| Predictions | Polymarket | Event betting on Polygon |
This is their most innovative feature. Users describe automation in natural language, and Pigeon generates deterministic code that runs on schedule:
// User says: "Every 15 min, alert me if SOL falls below $150"
// Pigeon generates monitoring code that:
// 1. Polls SOL price every 15 minutes
// 2. Compares against threshold
// 3. Sends notification if condition met
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER INTERFACES β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Telegram β β Discord β β Web β β API β β
β ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
βββββββββΌββββββββββββββΌββββββββββββββΌββββββββββββββΌββββββββββββββββ
β β β β
βββββββββββββββ΄βββββββ¬βββββββ΄ββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β GATEWAY / MESSAGE ROUTER β
β β’ Session management β’ Rate limiting β’ Auth β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ORCHESTRATOR AGENT β
β β’ Intent classification β’ Agent routing β’ Context mgmt β
β β’ Uses: Gemini 2.5 Flash (fast) or Pro (complex) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌβββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ
β RESEARCH AGENTβ β TRADING AGENT β β STRATEGY AGENTβ
β β’ Market data β β β’ Order exec β β β’ Backtest β
β β’ Sentiment β β β’ Position β β β’ Code gen β
β β’ News β β β’ Risk mgmt β β β’ Monitoring β
βββββββββ¬ββββββββ βββββββββ¬ββββββββ βββββββββ¬ββββββββ
β β β
ββββββββββββββββββ¬ββ΄βββββββββββββββββββ
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β TOOL LAYER (MCP) β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Hyperliquid β β CoinGecko β β MongoDB β β
β β SDK β β API β β Store β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Purpose: Handle multi-platform messaging, session management, authentication
Recommended: Python + FastAPI or use existing frameworks
Purpose: Classify user intent, route to specialized agents, maintain context
Recommended: Use Gemini 2.5 Flash for routing (fast + cheap), Pro for complex reasoning
# Intent Classification
intents = [
"price_check", # "What's BTC price?"
"open_position", # "Long ETH 10x"
"close_position", # "Close my BTC position"
"set_alert", # "Alert me if SOL > 200"
"portfolio_check", # "Show my positions"
"strategy_create", # "Create a grid trading strategy"
"backtest", # "Backtest this strategy"
]
Purpose: Execute trades, manage positions, handle risk
from hyperliquid.info import Info
from hyperliquid.exchange import Exchange
# Core operations to implement:
class HyperliquidAgent:
async def get_price(self, symbol: str) -> float
async def open_position(self, symbol: str, side: str, size: float, leverage: int)
async def close_position(self, symbol: str, percentage: float = 100)
async def set_stop_loss(self, symbol: str, price: float)
async def set_take_profit(self, symbol: str, price: float)
async def get_positions(self) -> List[Position]
async def get_pnl(self) -> PnLSummary
Purpose: Help users build, backtest, and deploy trading strategies
This is where you can differentiate from Pigeon:
// Collections
// users - User accounts and settings
{
_id: ObjectId,
platform: "telegram",
platform_id: "123456789",
wallet_address: "0x...", // Hyperliquid wallet
settings: {
default_leverage: 5,
max_position_size: 1000,
risk_per_trade: 0.02
},
created_at: ISODate
}
// strategies - User-created strategies
{
_id: ObjectId,
user_id: ObjectId,
name: "ETH Grid Bot",
type: "grid",
parameters: {
symbol: "ETH",
lower_bound: 3000,
upper_bound: 4000,
grid_count: 10,
size_per_grid: 0.1
},
status: "active",
performance: {
total_pnl: 150.5,
win_rate: 0.65,
trades_count: 42
}
}
// trades - Trade history
{
_id: ObjectId,
user_id: ObjectId,
strategy_id: ObjectId, // null for manual trades
symbol: "BTC",
side: "long",
entry_price: 45000,
exit_price: 46500,
size: 0.1,
pnl: 150,
timestamp: ISODate
}
// alerts - Price/condition alerts
{
_id: ObjectId,
user_id: ObjectId,
symbol: "SOL",
condition: "price_above",
threshold: 200,
triggered: false,
created_at: ISODate
}
Pigeon tries to be everything. You focus on Hyperliquid perps excellence. Deep integration, better UX for perps traders.
Pigeon Code is generic. You offer pre-built perps strategies with backtesting. Grid bots, DCA, momentum, mean reversion.
Funding rate analysis, open interest tracking, liquidation heatmaps β perps-specific research Pigeon doesn't have.
Pigeon charges 4bps. Consider 2bps or free during beta to acquire users.
Since your team is new to AI development, here's a structured learning path:
Build a simple chatbot that can:
# Goal: "What's BTC price?" β Calls CoinGecko β "BTC is $45,000"
| Framework | Best For | Learning Curve |
|---|---|---|
| fast-agent | MCP-enabled agents, what Pigeon uses | Medium |
| LangChain | General purpose, huge ecosystem | Medium |
| LlamaIndex | RAG, data retrieval | Easy |
| OpenAI Agents SDK | Simple multi-agent | Easy |
| Custom (recommended for MVP) | Full control, simpler | Easy |
Deliverable: Bot that responds to "hi" and can fetch BTC price
Deliverable: "Long BTC 5x" actually works
| Component | Recommendation | Why |
|---|---|---|
| Language | Python 3.11+ | Best AI ecosystem, Hyperliquid SDK is Python, GCP/Gemini have great Python support |
| Package Manager | uv or Poetry | Modern, fast, better than pip |
| LLM | Gemini 2.5 Flash (primary), Pro (complex) | You have GCP credits, fast, good function calling |
| Database | MongoDB Atlas | You have credits, flexible schema for rapid iteration |
| Bot Framework | python-telegram-bot | Mature, async, well-documented |
| Trading | hyperliquid-python-sdk | Official SDK, well-maintained |
| Web Framework | FastAPI | If you need API endpoints later, async, fast |
| Task Queue | Celery + Redis (later) | For strategy execution, alerts β not needed for MVP |
| Hosting | GCP Cloud Run or Compute Engine | You have credits, easy deployment |
moar-perps/
βββ pyproject.toml # Dependencies (use uv or poetry)
βββ .env # Secrets (never commit!)
βββ src/
β βββ __init__.py
β βββ main.py # Entry point
β βββ config.py # Configuration
β βββ bot/
β β βββ __init__.py
β β βββ telegram.py # Telegram bot handlers
β β βββ handlers.py # Command handlers
β βββ agents/
β β βββ __init__.py
β β βββ orchestrator.py # Main routing agent
β β βββ trading.py # Hyperliquid trading agent
β β βββ research.py # Market data agent
β βββ tools/
β β βββ __init__.py
β β βββ hyperliquid.py # Hyperliquid SDK wrapper
β β βββ coingecko.py # Price data
β β βββ gemini.py # LLM client
β βββ models/
β β βββ __init__.py
β β βββ user.py # User model
β β βββ trade.py # Trade model
β β βββ strategy.py # Strategy model
β βββ db/
β βββ __init__.py
β βββ mongo.py # MongoDB client
βββ tests/
β βββ ...
βββ README.md
"""
Minimal example: Gemini + Hyperliquid Price Check
"""
import google.generativeai as genai
from hyperliquid.info import Info
import json
# Configure Gemini
genai.configure(api_key="YOUR_GEMINI_API_KEY")
# Define tools
tools = [
{
"name": "get_crypto_price",
"description": "Get the current price of a cryptocurrency on Hyperliquid",
"parameters": {
"type": "object",
"properties": {
"symbol": {
"type": "string",
"description": "The trading symbol, e.g., BTC, ETH, SOL"
}
},
"required": ["symbol"]
}
}
]
# Tool implementation
def get_crypto_price(symbol: str) -> dict:
info = Info(skip_ws=True)
meta = info.meta()
# Find the asset
for asset in meta["universe"]:
if asset["name"] == symbol:
# Get mid price
l2 = info.l2_snapshot(asset["name"])
bid = float(l2["levels"][0][0]["px"])
ask = float(l2["levels"][1][0]["px"])
mid = (bid + ask) / 2
return {"symbol": symbol, "price": mid}
return {"error": f"Symbol {symbol} not found"}
# Chat function
def chat(user_message: str):
model = genai.GenerativeModel(
"gemini-2.5-flash",
tools=tools,
system_instruction="You are a helpful trading assistant for Hyperliquid perps."
)
response = model.generate_content(user_message)
# Handle function calls
if response.candidates[0].content.parts[0].function_call:
fc = response.candidates[0].content.parts[0].function_call
if fc.name == "get_crypto_price":
result = get_crypto_price(fc.args["symbol"])
# Send result back to model
response = model.generate_content([
user_message,
{"function_call": fc},
{"function_response": {"name": fc.name, "response": result}}
])
return response.text
# Test
print(chat("What's the price of ETH?"))
For teams that can dedicate full-time effort and are comfortable with some technical debt.
uv or Poetry.env)python-telegram-bot/start with welcome messageget_price tool (CoinGecko or Hyperliquid)hyperliquid-python-sdkopen_position toolclose_position toolget_positions toolMore sustainable pace with better architecture, testing, and room for iteration.
get_price(symbol)get_funding_rate(symbol)open_long(symbol, size, leverage)open_short(symbol, size, leverage)close_position(symbol, percentage)set_stop_loss(symbol, price)set_take_profit(symbol, price)/settings)| Feature | 2-Week MVP | 4-Week MVP |
|---|---|---|
| Price checking | β | β |
| Open/close positions | β | β |
| Stop-loss/Take-profit | β | β |
| Portfolio view | β | β |
| Multi-user support | β | β |
| Conversation memory | Basic | β |
| Risk limits | Basic | β Full |
| Price alerts | β | β |
| Funding rate tools | β | β |
| Trade history | β | β |
| Paper trading mode | β | β |
| CI/CD pipeline | β | β |
| Monitoring/Logging | Basic | β Full |
| Test coverage | ~30% | ~70% |
| Dev | Focus Area | Key Deliverables |
|---|---|---|
| Dev 1 (Backend Lead) | LLM + Orchestration | Gemini integration, function calling, intent routing |
| Dev 2 (Trading) | Hyperliquid + MongoDB | SDK wrapper, trade execution, data storage |
| Dev 3 (Frontend/Ops) | Telegram Bot + DevOps | Bot UX, CI/CD, deployment, monitoring |