Evan-Kim2028 / uniswap_subgraph_downloader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uniswap Swaps Subgraph Downloader

This tool allows you to quickly query historical swap data from univ2 and univ3 subgraphs.

Setup

After cloning the repository, create a virtual environment and install subgrounds

Virtual Environment

  1. Install virtual environment:

    python3 -m venv .venv
  2. Activate virtual environment:

    source .venv/bin/activate
  3. Install Subgrounds:

    pip install subgrounds

Playgrounds API Key

  1. Sign up for a playgrounds API key to get 5000 free queries here.

  2. Load the API key into the local environment variable using bash.

    For 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

Usage

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)

About


Languages

Language:Jupyter Notebook 87.9%Language:Python 12.1%