uniswappeR

R Package to Interact and Trade with Uniswap Platform and Exploration of Uniswap data from GraphQL.
Install Using
devtools::install_github("Omni-Analytics-Group/uniswappeR")

The package has 3 Functionalities - Trade : To query prices and make trades on Uniswap from R console - Pull Data : To pull all types of data from Uniswap GraphQL to explore yourself - Explore Data : To Analyse and explore the uniswap data


Trade Functionality

Description

Our uniswappeR R package includes the functionality to trade and query prices from the Uniswap Platform. To interact with the Uniswap Platform we need to configure the environment and then we can use the functions to make trades on the uniswap platform and query prices.

View the video walkthrough on how to conduct trades through UniswappeR here.

Walkthrough

0. (Optional Environment Setup) If you want to use the trade functionality of the package.

1. Use the Virtual Environment generated above

2. Use your Infura Node

set_infura_node("https://mainnet.infura.io/v3/XXXXXXXXXXXXXXXXXXX")

3. Setup a uniswap session using your address and private key. Choose UniswapV2 or UniswapV3 by supplying the version as 2 or 3 respectively.

u_w <- uniswap_session(user_add = "**", pvt_key = "***", version = 3)

4. Helper Functions to Check Balances and Query Prices

5. Trade Functions to make swaps on Uniswap


Pull Data Functionality

Description

Our uniswappeR R package contains the codebase that abstracts away the GraphQL layer of querying for uniswap data into a user-friendly R package.

View the video walkthrough on how to pull data into R using UniswappeR.

Walkthrough

1. Load the package.

2. View Stats or Historical Stats across all pairs generated by Uniswap Factory

3. View Stats or Historical Stats for a specific token across all pairs that token is included in

4. For a specific Token get stats for all pairs the Token is either Base or Quote

5. Fetch All Pairs deployed

6. View Stats or Historical Stats for a specific Pair

7. View Liquidity Positions or Historical LPs for a specific Pair

8. Get Mints/Burns/Swaps Txs from a specific Pair

9. View Liquidity Positions or Historical LPs for a specific User

10. Get Mints/Burns/Swaps Txs from a specific User

11. Export any of the pulled data as CSV file


Data Exploration Functionality

Description

Our uniswappeR R package includes a number of high level functions for interacting and visualising the data from uniswap:

Walkthrough

1. UniswapV3 Pair Token Liquidity Range Forecast.

The below code snippet provides a forecast using geometric Brownian motion its tunable parameters are the Pair’s Address, forecast window, max % increase that can occur in a single day, and number of simulations, respectively. The resulting output is a data frame with the liquidity range forecast.

UniswapV3 Pair Liquidity Range Forecast

This provides the suggested range for the liquidity. - liquidity_range_v3(pair_address = "0x1d42064fc4beb5f8aaf85f4617ae8b3b5b8bd801")

UniswapV3 Pair Liquidity Range

2. Liquidity Range Estimates Visualisation

Allows for the visualisation of the GBM process for a Pair’s address. Additionally ggplot pipelines can be added to modify the visualisation.

3. Uniswap Platform Growth

This section introduces various visualisations within uniswappeR.

This allows the user to visualise various growth metrics of the UniswapV2 Platform. From this, insights about daily volume, liquidity, and transaction counts can be analyzed. For example, we can infer that the amount of transactions overtime is steadily increasing, and that there is not a clear, discernible pattern for the daily volume nor liquidity.

Uniswap Platform Growth

This allows the user to visualise various growth metrics of the UniswapV3 Platform. From this, insights about daily volume, liquidity, and transaction counts can be analyzed. This visual quickly allows us to see that sometime around March 2022, a large spike occured for the daily volume. This this enables the curious user to explore in further detail the events that occurred that day.

Uniswap Platform Growth

4. Token Growth

This allows the user to visualise various growth metrics of a given token in UniswapV2. Similar to the other historical stats functions, this allows the user to see past trends for a specific token on UniswapV2. From this we can quickly notice a downward trend in token liquidity signaling a rush on that token.

Token Growth

This allows the user to visualise various growth metrics of a given token in UniswapV3. Similar to the other historical stats functions, this allows the user to see past trends for a specific token on UniswapV3. One quick insight we can gather is that there appears to be a progressively less popularity in this token’s trade volume which is allow, perhaps, correlating with the token’s price.

Token Growth

5. Token Number of Pairs Growth

The below visual provides an indication of how often a given token is in a pair where token0 and token1 are given by the sorting order.

Token Growth

The below visual provides an indication of how often a given token is in a pair where token0 and token1 are given by the sorting order.

Token Growth

6. Pair Growth

The following provides a vasual of various growth metrics of a given pair in UniswapV2. In this example the pair_address is UNI to DAI.

Pair Growth

The following provides a vasual of various growth metrics of a given pair in UniswapV3.

Pair Growth

7. Liquidity Token Distribution

Allows for a user to visualise liquidity positions spread in a given pair via a histogram. One insight we can gather from this is that one address is providing about 1450 tokens to the LP whereas most others are contributing substaintially less.

Liquidity Token Distribution

8. User Swap Performance

Allows a user to retrieve all the swaps data for a given address or addresses. This allows a user to readily recognize their level of activity.

9. Save analysis plot


Significant Updates

5/14/2022

3/9/2022

About Us

Omni Analytics Group is an incorporated group of passionate technologists who help others use data science to change the world. Our practice of data science leads us into many exciting areas where we enthusiastically apply our machine learning, artificial intelligence and analysis skills. Our flavor for this month, the blockchain! To learn more about what we do or just to have fun, join us over on Twitter.