This project provides a tool to analyze and track swap transactions in Solana pools. It uses the Solscan API to fetch and process pool transfer data, making it easy to analyze trading activity within specific time periods.
- Fetch and analyze pool transfers from Solana blockchain
- Process swap transactions with detailed information
- Support for mock data testing
- Rate limiting and retry mechanisms for API calls
- Data processing and formatting capabilities
Before you begin, ensure you have the following installed:
- Python 3.7 or higher
- pip (Python package installer)
- Clone this repository:
git clone <https://github.com/stefi-says/solana_pools_get_data>
cd <solana_pools_get_data>
- Create a virtual environment (recommended):
python -m venv venv
- Activate the virtual environment:
- On Windows:
.\venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- Install the required dependencies:
pip install -r requirements.txt
- Create a
.env
file in the project root and add your Solscan API key:
SOLSCAN_API_KEY=your_api_key_here
Here's a basic example of how to use the SolanaPoolAnalyzer:
from get_pool_data import SolanaPoolAnalyzer
# Initialize the analyzer with a pool address
pool_analyzer = SolanaPoolAnalyzer(pool_address="your_pool_address")
# Get swap data for a specific date range
swaps = pool_analyzer.get_swaps(
from_date="2024-01-01",
to_date="2024-01-02",
use_mock_data=False # Set to True to use mock data
)
# Print the results
print(swaps)
The output DataFrame contains the following columns:
trans_id
: Transaction IDdatetime
: Transaction datetimetimestamp
: Transaction timestampowner_address
: Address of the swap initiatortoken_in_address
: Address of the input tokenamount_in
: Amount of input tokentoken_out_address
: Address of the output tokenamount_out
: Amount of output token
The project includes mock data for testing purposes. To use mock data, set use_mock_data=True
when calling get_swaps()
.
The script includes built-in rate limiting to prevent API throttling. By default, there's a 0.2-second delay between API calls. You can adjust this by modifying the rate_sleep_delay
parameter when initializing the SolanaPoolAnalyzer.
[ ] double test function using real calls and data
[ ] analyse integration of ThreadPoolExecutor to optmize execution time
[ ] integrate caching and logging for data extraction
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.