Skip to content

oasisprotocol/template-rofl-hl-copy-trader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hyperliquid Copy Trader 📈

An automated copy trading bot powered by Oasis Protocol's secure TEE infrastructure that replicates trades from expert traders on Hyperliquid DEX.

Quick Start

Run locally

  1. Clone the repository:
git clone https://github.com/oasisprotocol/template-rofl-hl-copy-trader.git
cd template-rofl-hl-copy-trader
  1. Install dependencies:
pip install -r requirements.txt
  1. Set environment variables and run:
export COPY_TRADE_ADDRESS="0x..."
export WITHDRAW_FUNDS_TO="0x..."
python -m src.main

Run inside Docker

docker compose up

Run as a ROFL app

rm rofl.yaml

oasis rofl init
oasis rofl create

oasis rofl build

oasis rofl secret set COPY_TRADE_ADDRESS "0x..."
oasis rofl secret set WITHDRAW "true"
oasis rofl secret set WITHDRAW_FUNDS_TO "0x..."

oasis rofl update
oasis rofl deploy

Configuration

Required Environment Variables

  • COPY_TRADE_ADDRESS: Address of the trader to copy (required)
  • WITHDRAW_FUNDS_TO: Emergency withdrawal address (required)
  • WITHDRAW: If set to true, the service will withdraw all funds to the WITHDRAW_FUNDS_TO address and exit. (optional)

Architecture

src/
├── clients/                  # External API integrations
│   ├── hyperliquid.py        # Hyperliquid DEX client
│   └── rofl.py               # ROFL key management client
├── config/                   # Configuration management
├── core/                     # Core business logic
│   ├── copy_trader.py        # Main orchestrator
│   ├── position_manager.py   # Position sizing and ratios
│   ├── trade_executor.py     # Order execution
│   ├── trade_monitor.py      # Real-time trade monitoring
│   └── withdrawal_handler.py # Emergency withdrawals
├── models/                   # Data models and types
└── main.py                   # Application entry point

How It Works

  1. Initialization: Connects to Hyperliquid and generates secure keypair via ROFL
  2. Monitoring: Subscribes to target trader's fills via WebSocket
  3. Position Sizing: Calculates proportional trade sizes based on account ratios
  4. Execution: Replicates trades with appropriate leverage and sizing
  5. Safety: Includes emergency withdrawal mode for fund recovery

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Support

For issues and questions, please open a GitHub issue.

About

[TEMPLATE] Hyperliquid Copy Trader running in Oasis ROFL.

Topics

Resources

License

Stars

Watchers

Forks

Contributors