This tool allows you to quickly query historical swap data from univ2 and univ3 subgraphs.
After cloning the repository, create a virtual environment and install subgrounds
-
Install virtual environment:
python3 -m venv .venv
-
Activate virtual environment:
source .venv/bin/activate
-
Install Subgrounds:
pip install subgrounds
-
Sign up for a playgrounds API key to get 5000 free queries here.
-
Load the API key into the local environment variable using bash.
-
Open or create your Bash configuration file (e.g.,
~/.bashrc
or~/.bash_profile
) using a text editor.nano ~/.bashrc
-
Add the following line at the end of the file, replacing "your_api_key_here" with your actual API key:
export PLAYGROUNDS_API_KEY="your_api_key_here"
-
Save the file and exit the text editor.
-
Apply the changes immediately:
source ~/.bashrc
-
Run the following commands to query the subgraphs using the format python univ3_substreams_async.py <date> <days>
. For example the below examples will query the subgraphs swap entity for the 7 days following 2023-11-20:
python univ3_substreams_async.py 2023-11-20 7
python univ2_async.py 2023-11-20 7
Note the query size is set at 2,500. Set the QUERY_SIZE
variable to a very large number to download the entire swaps for the day (~250,000 size should be more than enough)