This Go program queries the Uniswap V2 subgraph using the GraphQL API to fetch the pair data, including liquidity, trading volume, and the number of users. The program runs every minute to provide updated information.
- Go programming language installed
- An API key for The Graph's GraphQL API
- github.com/joho/godotenv
- github.com/levigross/grequests
- github.com/tidwall/gjson
Create a new directory for the project and navigate to it:
mkdir uniswap-monitor cd uniswap-monitor
Create a .env
file in the project directory with the following content:
Replace your_api_key_here
with your actual API key.
Install the required Go libraries:
go get github.com/joho/godotenv go get github.com/levigross/grequests go get github.com/tidwall/gjson
Create a new file called bc-go-uniswap-monitor.go
in the project directory and add the previously provided Go code to it.
Run the program using the following command:
The program will output the fetched pair data every minute, including liquidity, trading volume, and number of users.