Home

Awesome

uniswappeR

R Package to Interact and Trade with Uniswap Platform and Exploration of Uniswap data from GraphQL.<br> Install Using <br> devtools::install_github("OmniacsDAO/uniswappeR")

The package has 3 Functionalities

<hr>

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)<br>

4. Helper Functions to Check Balances and Query Prices

5. Trade Functions to make swaps on Uniswap

<hr>

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

<hr>

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.

<img src="man/figures/liquidity_range_all_v3.png" align="center"/> <div align="center">UniswapV3 Pair Liquidity Range Forecast</div>

This provides the suggested range for the liquidity.

<img src="man/figures/liquidity_range_v3.png" align="center"/> <div align="center">UniswapV3 Pair Liquidity Range</div>

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.

<img src="man/figures/vis_uniswap_stats_hist_v2.png" align="center"/> <div align="center">Uniswap Platform Growth</div>

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.

<img src="man/figures/vis_uniswap_stats_hist_v3.png" align="center"/> <div align="center">Uniswap Platform Growth</div>

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.

<img src="man/figures/vis_token_stats_hist_v2.png" align="center"/> <div align="center">Token Growth</div>

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.

<img src="man/figures/vis_token_stats_hist_v3.png" align="center"/> <div align="center">Token Growth</div>

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.

<img src="man/figures/vis_token_pair_map_v2.png" align="center"/> <div align="center">Token Growth</div>

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.

<img src="man/figures/vis_token_pair_map_v3.png" align="center"/> <div align="center">Token Growth</div>

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.

<img src="man/figures/vis_pair_stats_hist_daily_v2.png" align="center"/> <div align="center">Pair Growth</div>

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

<img src="man/figures/vis_pair_stats_hist_daily_v3.png" align="center"/> <div align="center">Pair Growth</div>

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.

<img src="man/figures/vis_pair_liq_positions_v2.png" align="center"/> <div align="center">Liquidity Token Distribution</div> <img src="man/figures/vis_pair_liq_positions_v3.png" align="center"/> <div align="center">Liquidity Token Distribution</div>

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.

<!-- - `swap_performance(swap_data)` <img src="man/figures/example3_pricechange.png" align="center"/> -->

9. Save analysis plot

<hr>

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.