Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xternet/lend-borrow-utilization-fetcher
Fetching utilization rates from Aave and Compound using subgraphs.
https://github.com/xternet/lend-borrow-utilization-fetcher
aave analytics blockchain borrowing compound defi evm graphql lending subgraphs utilization
Last synced: about 2 months ago
JSON representation
Fetching utilization rates from Aave and Compound using subgraphs.
- Host: GitHub
- URL: https://github.com/xternet/lend-borrow-utilization-fetcher
- Owner: xternet
- Created: 2024-09-09T22:08:00.000Z (5 months ago)
- Default Branch: master
- Last Pushed: 2024-09-13T16:10:01.000Z (5 months ago)
- Last Synced: 2024-10-31T11:05:37.390Z (3 months ago)
- Topics: aave, analytics, blockchain, borrowing, compound, defi, evm, graphql, lending, subgraphs, utilization
- Language: TypeScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lend-borrow-utilization-fetcher
This project fetches, stores, and visualizes utilization rates from Aave and Compound using subgraphs. By leveraging subgraphs, historical data can be retrieved in minutes instead of weeks using multicall methods. Check if the protocol has subgraphs available at [The Graph Explorer](https://thegraph.com/explorer) for streamlined analytics.
### Setup Instructions
1. **Rename Environment File:**
- Rename the `.env_example` file to `.env`:
```bash
mv .env_example .env
```2. **Provide The Graph API Key:**
- Visit [The Graph](https://thegraph.com/) to obtain a free API key.
- After obtaining the key, rename `.env_example` to `.env` and add the API key to the appropriate field:
```
API_GRAPHQL=your-api-key-here
```### Optional: Skip Fetching Data
If you'd like to skip the fetching process, you can download the pre-fetched 2024-09-10 snapshot:
1. **Download the data from GitHub and extract it into the `./data/` directory:**
```bash
wget https://github.com/xternet/lend-borrow-utilization-fetcher/releases/download/data-download/2024-09-10-utilization-rates.tar.gz && mkdir ./data && tar -xzvf 2024-09-10-utilization-rates.tar.gz -C ./data/
```### Python Script Setup
The project includes a Python script for visualizing utilization rate data from CSV files.
#### Prerequisites:
- Install Python 3.
- Install the required Python libraries:
```bash
pip install pandas matplotlib
```#### Running the Python Script
1. Navigate to the project directory:
```bash
cd lend-borrow-utilization-fetcher
```2. Run the Python chart generator:
```bash
python3 src/make-chart.py
```- The script will ask for the protocol, chain, and tokens to visualize.
- You can either view the chart interactively or save it to a file in the `data/charts` directory.### Project Structure
```bash
lend-borrow-utilization-fetcher/
├── node_modules/ # Dependencies
├── src/ # Source code
│ ├── fetch-data.ts # Fetch data from protocols
│ ├── load-data.ts # Load and process CSV files
│ └── make-chart.py # Generate charts from CSV files
├── data/ # Data directory (includes CSV and chart data)
│ ├── utilization-rates/ # CSV data directory
│ ├── charts/ # Directory for saving charts
├── package.json # Project metadata
└── README.md # Documentation
```### Example CSV Directory Structure
```bash
data/
├── utilization-rates/
│ ├── aaveV2/
│ │ ├── mainnet/
│ │ │ └── aaveV2-mainnet-DAI.csv
│ ├── aaveV3/
│ ├── compoundV2/
│ └── compoundV3/
```### Commands
#### Install Dependencies
```bash
bun install
```#### Fetch Data
```bash
bun run fetch-data
```- Connects to Aave and Compound subgraphs.
- Fetches utilization rates and stores them in `data/utilization-rates/`.#### Compress Data
```bash
bun run tar-data
```- Compresses the `data/utilization-rates/` directory into a tar.gz file.
#### Generate Chart with Python Script
```bash
python3 src/make-chart.py
```# lend-borrow-utilization-fetcher
This project fetches, stores, and visualizes utilization rates from Aave and Compound using subgraphs. By leveraging subgraphs, historical data can be retrieved in minutes instead of weeks using multicall methods. Check if the protocol has subgraphs available at [The Graph Explorer](https://thegraph.com/explorer) for streamlined analytics.
### Setup Instructions
1. **Rename Environment File:**
- Rename the `.env_example` file to `.env`:
```bash
mv .env_example .env
```2. **Provide The Graph API Key:**
- Visit [The Graph](https://thegraph.com/) to obtain a free API key.
- After obtaining the key, rename `.env_example` to `.env` and add the API key to the appropriate field:
```
API_GRAPHQL=your-api-key-here
```### Optional: Skip Fetching Data
If you'd like to skip the fetching process, you can download the pre-fetched 2024-09-10 snapshot:
1. **Download the data from GitHub and extract it into the `./data/` directory:**
```bash
wget https://github.com/xternet/lend-borrow-utilization-fetcher/releases/download/data-download/2024-09-10-utilization-rates.tar.gz && mkidr ./data && tar -xzvf 2024-09-10-utilization-rates.tar.gz -C ./data/
```### Python Script Setup
The project includes a Python script for visualizing utilization rate data from CSV files.
#### Prerequisites:
- Install Python 3.
- Install the required Python libraries:
```bash
pip install pandas matplotlib
```#### Running the Python Script
1. Navigate to the project directory:
```bash
cd lend-borrow-utilization-fetcher
```2. Run the Python chart generator:
```bash
python3 src/make-chart.py
```- The script will ask for the protocol, chain, and tokens to visualize.
- You can either view the chart interactively or save it to a file in the `data/charts` directory.### Project Structure
```bash
lend-borrow-utilization-fetcher/
├── node_modules/ # Dependencies
├── src/ # Source code
│ ├── fetch-data.ts # Fetch data from protocols
│ ├── load-data.ts # Load and process CSV files
│ └── make-chart.py # Generate charts from CSV files
├── data/ # Data directory (includes CSV and chart data)
│ ├── utilization-rates/ # CSV data directory
│ ├── charts/ # Directory for saving charts
├── package.json # Project metadata
└── README.md # Documentation
```### Example CSV Directory Structure
```bash
data/
├── utilization-rates/
│ ├── aaveV2/
│ │ ├── mainnet/
│ │ │ └── aaveV2-mainnet-DAI.csv
│ ├── aaveV3/
│ ├── compoundV2/
│ └── compoundV3/
```### Commands
#### Install Dependencies
```bash
bun install
```#### Fetch Data
```bash
bun run fetch-data
```- Connects to Aave and Compound subgraphs.
- Fetches utilization rates and stores them in `data/utilization-rates/`.#### Compress Data
```bash
bun run tar-data
```- Compresses the `data/utilization-rates/` directory into a tar.gz file.
#### Generate Chart with Python Script
```bash
python3 src/make-chart.py
```