Expand description
§Solana Copy Trading Library
Live execution system for copying trades from high-performing Solana wallets.
This library provides the core components for a copy trading system that:
- Monitors swap transactions from tracked wallets
- Automatically opens positions when tracked wallets buy tokens
- Manages position lifecycle (opening, monitoring, closing)
- Implements stop-loss and hold-time strategies
- Executes trades via Jito bundles for fast settlement
§Architecture
- PositionManager: Central coordinator that monitors swap transactions, market updates, and new pool creations. Manages multiple positions simultaneously.
- Position: Represents a single copy trading position with state management and lifecycle handling.
- PositionConfig: Configuration for each tracked wallet defining buy amounts, hold times, stop-loss settings.
§Position Lifecycle
- Created: Position created when a tracked wallet buys a token
- Opening: Buy transaction sent to blockchain via Jito
- Open: Position actively monitored for stop-loss triggers and hold time expiration
- Closing: Sell transaction sent to blockchain
- Closed: Position finalized and removed from active tracking
LOTS OF FUNCTIONS UNDER IMPLEMENTATIONS OF POSITION AND POSITION MANAGER ARE DOCUMENTED IN THE CODE.
Structs§
- Position
- Represents a single copy trading position tracking a token purchase from a monitored wallet. Contains all state for a position including entry/exit prices, timestamps, stop-loss settings, and lifecycle status. Positions are managed through a state machine with transitions: Created -> Opening -> Open -> Closing -> Closed.
- Position
Config - Configuration for copy trading a specific wallet, defining position sizing and risk management. Each tracked wallet has its own configuration specifying buy amounts, hold times, stop-loss thresholds, and slippage tolerances.
- Position
Manager - Central coordinator for managing copy trading positions and monitoring wallet activity. Monitors swap transactions, market updates, and new pool creations, automatically opening and closing positions based on tracked wallet behavior. It maintains active positions and wallet configurations for copy trading.
Enums§
- Position
Close Reason - Reason why a position was closed.
- Position
Status - Represents the current lifecycle state of a position. Positions transition through these states: Created -> Opening -> Open -> Closing -> Closed.
Functions§
- set_
wallet_ configs_ from_ pl_ df - Set wallet configurations from a Polars DataFrame. Clears existing wallet configs and loads new configurations from a DataFrame containing wallet addresses and their position configuration parameters.