class: center, middle, inverse, title-slide # PoolTogether Analysis
### Omni Analytics Group --- ## PoolTogether PoolTogether is a fun, open sourced and decentralized protocol for “no-loss” lotteries where users transfer their crypto into a shared pool that acts as a “prize-linked savings account”. These deposits double as lottery tickets that give the depositor a chance to win proportional to the amount of the pool they claim. Just like traditional savings accounts, all money in the pool earns a yield and each user can withdraw at their discretion. #### Prizes At the time of this writing, \$3,801,856 worth of prizes have been awarded. Also, based on current deposits, the platform has been generating \$93,558 in interest per week for its users. Interested in earning? You can participate in PoolTogether on the Ethereum, xDai, Matic, and Binance Smart Chain networks. #### Proposals True to the spirit of decentralization, the PoolTogether protocol is managed by holders of the $POOL governance token who draft and vote on proposals that control the prize creation tools and prize pools. Proposals are ratified through a voting process and are then implemented by the community. --- ## Data To begin, we need to scrape the data. The code is provided below, if desired. The procedure for data scraping is: 1. Retrieve the network/chain pool data from the pool together API json files. 2. Parse the JSON / nested list structure into an R dataframe. 3. Retrieve the rewards / prize history by making a GraphQL call to TheGraph's API. 4. Retrieve information on the holders by making a GraphQL call to TheGraph's API. 5. Save the three objects as R Data Files. We accomplish this using a custom R-based routine and the following libraries: ```r library(tidyverse) library(httr) library(jsonlite) library(lubridate) library(ghql) ``` --- ## Data Loading Next, with the data successfully scraped, we read in the R data objects into our local environment and take a look at the raw data. To the rewards data, we add an indicator of the pool name for each. ```r # Read the objects into the environment pools_data <- readRDS("data/pools_data.RDS") holders_data <- readRDS("data/holders_data.RDS") rewards_data <- readRDS("data/rewards_data.RDS") # Store the pool name int he rewards data for (i in 1:length(rewards_data)) { if (nrow(rewards_data[[i]]) > 0) { rewards_data[[i]]$Pool <- pools_data$Name[i] } } ``` --- ## Pools Data We can take a look at the first few rows of the pool data: <table class="table table-striped table-hover" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Name </th> <th style="text-align:left;"> Symbol </th> <th style="text-align:left;"> Address </th> <th style="text-align:left;"> Subgraph_Version </th> <th style="text-align:left;"> Num_Winners </th> <th style="text-align:left;"> Prize_Freq_Secs </th> <th style="text-align:left;"> Pool_Type </th> <th style="text-align:left;"> Base_Tok_Address </th> <th style="text-align:left;"> Base_Tok_Decimals </th> <th style="text-align:left;"> Base_Tok_Name </th> <th style="text-align:left;"> Base_Tok_Symbol </th> <th style="text-align:right;"> Base_Tok_Val_USD </th> <th style="text-align:left;"> Ticket_Address </th> <th style="text-align:left;"> Ticket_Decimals </th> <th style="text-align:left;"> Ticket_Name </th> <th style="text-align:left;"> Ticket_Symbol </th> <th style="text-align:left;"> Num_Ticket_Holders </th> <th style="text-align:left;"> Ticket_Val_Base_Tok </th> <th style="text-align:left;"> Ticket_Val_USD </th> <th style="text-align:left;"> Sponsorship_Address </th> <th style="text-align:left;"> Sponsorship_Decimals </th> <th style="text-align:left;"> Sponsorship_Name </th> <th style="text-align:left;"> Sponsorship_Symbol </th> <th style="text-align:left;"> Num_Sponsorship_Holders </th> <th style="text-align:left;"> Sponsorship_Val_Base_Tok </th> <th style="text-align:left;"> Sponsorship_Val_USD </th> <th style="text-align:left;"> Reserve_Val_Base_Tok </th> <th style="text-align:left;"> Reserve_Val_USD </th> <th style="text-align:left;"> Reserve_Rate </th> <th style="text-align:left;"> Daily_Reward </th> <th style="text-align:left;"> Daily_Reward_Token_Name </th> <th style="text-align:left;"> Daily_Reward_Token_Decimals </th> <th style="text-align:left;"> Daily_Reward_Token_Symbol </th> <th style="text-align:left;"> Daily_Reward_Token_Val_USD </th> <th style="text-align:left;"> Effective_APR </th> <th style="text-align:left;"> Prize_Current_Index </th> <th style="text-align:left;"> Prize_Current_State </th> <th style="text-align:right;"> Prize_Remaining_Secs </th> <th style="text-align:left;"> Prize_Period_Started_At </th> <th style="text-align:left;"> Prize_Total_USD </th> <th style="text-align:left;"> Prize_Internal </th> <th style="text-align:left;"> Prize_External </th> <th style="text-align:left;"> Prize_External_Yield </th> <th style="text-align:left;"> Prize_External_ERC20 </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> DAI Pool </td> <td style="text-align:left;"> PT-cDAI </td> <td style="text-align:left;"> 0xebfb47a7ad0fd6e57323c8a42b2e5a6a4f68fc1a </td> <td style="text-align:left;"> 3.1.0 </td> <td style="text-align:left;"> 5 </td> <td style="text-align:left;"> 604800 </td> <td style="text-align:left;"> compound </td> <td style="text-align:left;"> 0x6b175474e89094c44da98b954eedeac495271d0f </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> Dai Stablecoin </td> <td style="text-align:left;"> DAI </td> <td style="text-align:right;"> 1.0025360 </td> <td style="text-align:left;"> 0x334cbb5858417aee161b53ee0d5349ccf54514cf </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> PoolTogether Dai Ticket (Compound) </td> <td style="text-align:left;"> PcDAI </td> <td style="text-align:left;"> 5518 </td> <td style="text-align:left;"> 27031562.847149068445242853 </td> <td style="text-align:left;"> 27031562.847149068445242853 </td> <td style="text-align:left;"> 0x0a2e7f69fe9588fa7fba5f5864236883cd4aac6d </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> PoolTogether Dai Sponsorship (Compound) </td> <td style="text-align:left;"> PDAIS </td> <td style="text-align:left;"> 3 </td> <td style="text-align:left;"> 253821.482766163126362001 </td> <td style="text-align:left;"> 253821.482766163126362001 </td> <td style="text-align:left;"> 380849.264812579060780233 </td> <td style="text-align:left;"> 380849.264812579060780233 </td> <td style="text-align:left;"> 0.5 </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> 44 </td> <td style="text-align:left;"> Awarded </td> <td style="text-align:right;"> 602543 </td> <td style="text-align:left;"> 2021-08-20 19:00:00 </td> <td style="text-align:left;"> 15118.16 </td> <td style="text-align:left;"> 6260.78 </td> <td style="text-align:left;"> 8857.38 </td> <td style="text-align:left;"> 8857.38 </td> <td style="text-align:left;"> 0.0 </td> </tr> <tr> <td style="text-align:left;"> UNI Pool </td> <td style="text-align:left;"> PT-cUNI </td> <td style="text-align:left;"> 0x0650d780292142835f6ac58dd8e2a336e87b4393 </td> <td style="text-align:left;"> 3.1.0 </td> <td style="text-align:left;"> 5 </td> <td style="text-align:left;"> 604800 </td> <td style="text-align:left;"> compound </td> <td style="text-align:left;"> 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> Uniswap </td> <td style="text-align:left;"> UNI </td> <td style="text-align:right;"> 28.4455677 </td> <td style="text-align:left;"> 0xa92a861fc11b99b24296af880011b47f9cafb5ab </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> PoolTogether UNI Ticket (Compound) </td> <td style="text-align:left;"> PcUNI </td> <td style="text-align:left;"> 1105 </td> <td style="text-align:left;"> 527492.142962408746066652 </td> <td style="text-align:left;"> 15007151.467280528825596249 </td> <td style="text-align:left;"> 0x5cfb96a0475afa385d28320de2aa1a21aa947c05 </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> PoolTogether UNI Sponsorship (Compound) </td> <td style="text-align:left;"> ScUNI </td> <td style="text-align:left;"> 0 </td> <td style="text-align:left;"> 0.0 </td> <td style="text-align:left;"> 0.0 </td> <td style="text-align:left;"> 446.164754509948929549 </td> <td style="text-align:left;"> 12693.387265808047045669 </td> <td style="text-align:left;"> 0.5 </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> 35 </td> <td style="text-align:left;"> Awarded </td> <td style="text-align:right;"> 343343 </td> <td style="text-align:left;"> 2021-08-17 19:00:00 </td> <td style="text-align:left;"> 3117.7 </td> <td style="text-align:left;"> 908.49 </td> <td style="text-align:left;"> 2209.21 </td> <td style="text-align:left;"> 1247.64 </td> <td style="text-align:left;"> 961.57 </td> </tr> <tr> <td style="text-align:left;"> USDC Pool </td> <td style="text-align:left;"> PT-cUSDC </td> <td style="text-align:left;"> 0xde9ec95d7708b8319ccca4b8bc92c0a3b70bf416 </td> <td style="text-align:left;"> 3.1.0 </td> <td style="text-align:left;"> 5 </td> <td style="text-align:left;"> 604800 </td> <td style="text-align:left;"> compound </td> <td style="text-align:left;"> 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 </td> <td style="text-align:left;"> 6 </td> <td style="text-align:left;"> USD Coin </td> <td style="text-align:left;"> USDC </td> <td style="text-align:right;"> 0.9982249 </td> <td style="text-align:left;"> 0xd81b1a8b1ad00baa2d6609e0bae28a38713872f7 </td> <td style="text-align:left;"> 6 </td> <td style="text-align:left;"> PoolTogether USDC Ticket (Compound) </td> <td style="text-align:left;"> PcUSDC </td> <td style="text-align:left;"> 2476 </td> <td style="text-align:left;"> 79653982.14181 </td> <td style="text-align:left;"> 79653982.14181 </td> <td style="text-align:left;"> 0x391a437196c81eea7bbbbd5ed4df6b49de4f5c96 </td> <td style="text-align:left;"> 6 </td> <td style="text-align:left;"> PoolTogether USDC Sponsorship (Compound) </td> <td style="text-align:left;"> ScUSDC </td> <td style="text-align:left;"> 4 </td> <td style="text-align:left;"> 6176431.811651 </td> <td style="text-align:left;"> 6176431.811651 </td> <td style="text-align:left;"> 560792.713127 </td> <td style="text-align:left;"> 560792.713127 </td> <td style="text-align:left;"> 0.5 </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> 33 </td> <td style="text-align:left;"> Awarded </td> <td style="text-align:right;"> 256943 </td> <td style="text-align:left;"> 2021-08-16 19:00:00 </td> <td style="text-align:left;"> 48006.39 </td> <td style="text-align:left;"> 21690.07 </td> <td style="text-align:left;"> 26316.32 </td> <td style="text-align:left;"> 18092.01 </td> <td style="text-align:left;"> 8224.31 </td> </tr> <tr> <td style="text-align:left;"> POOL Pool </td> <td style="text-align:left;"> PT-stPOOL </td> <td style="text-align:left;"> 0x396b4489da692788e327e2e4b2b0459a5ef26791 </td> <td style="text-align:left;"> 3.3.2 </td> <td style="text-align:left;"> 5 </td> <td style="text-align:left;"> 604800 </td> <td style="text-align:left;"> stake </td> <td style="text-align:left;"> 0x0cec1a9154ff802e7934fc916ed7ca50bde6844e </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> PoolTogether </td> <td style="text-align:left;"> POOL </td> <td style="text-align:right;"> 17.5355684 </td> <td style="text-align:left;"> 0x27d22a7648e955e510a40bdb058333e9190d12d4 </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> PoolTogether Pool Ticket (Stake) </td> <td style="text-align:left;"> PPOOL </td> <td style="text-align:left;"> 2018 </td> <td style="text-align:left;"> 951257.777699605648753597 </td> <td style="text-align:left;"> 16685061.420851083079138091 </td> <td style="text-align:left;"> 0x089811ed7da2e09ae29f99518004b5c388165b7c </td> <td style="text-align:left;"> 18 </td> <td style="text-align:left;"> PT Stake POOL Sponsorship </td> <td style="text-align:left;"> SSPOOL </td> <td style="text-align:left;"> 0 </td> <td style="text-align:left;"> 0.0 </td> <td style="text-align:left;"> 0.0 </td> <td style="text-align:left;"> 31.270374730242635937 </td> <td style="text-align:left;"> 548.482372768455834334 </td> <td style="text-align:left;"> 0.0 </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> 24 </td> <td style="text-align:left;"> Awarded </td> <td style="text-align:right;"> 99299 </td> <td style="text-align:left;"> 2021-08-14 23:12:36 </td> <td style="text-align:left;"> 4246.55 </td> <td style="text-align:left;"> 4246.55 </td> <td style="text-align:left;"> 0.0 </td> <td style="text-align:left;"> NA </td> <td style="text-align:left;"> 0.0 </td> </tr> </tbody> </table> --- ## Holders Data The holders of the first pool: <table class="table table-striped table-hover" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> id </th> <th style="text-align:left;"> balance </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> 0x052564eb0fd8b340803df55def89c25c432f43f4 </td> <td style="text-align:left;"> 4493219070921554199609132 </td> </tr> <tr> <td style="text-align:left;"> 0x30030383d959675ec884e7ec88f05ee0f186cc06 </td> <td style="text-align:left;"> 3284507114531434549903748 </td> </tr> <tr> <td style="text-align:left;"> 0xcaacebe2fdac9d3783563b9b80c714df82705226 </td> <td style="text-align:left;"> 1500000000000000000000000 </td> </tr> <tr> <td style="text-align:left;"> 0x2f994e2e4f3395649eee8a89092e63ca526da829 </td> <td style="text-align:left;"> 1359279159175702142539944 </td> </tr> </tbody> </table> --- ## Rewards Data The past rewards for the first pool: <table class="table table-striped table-hover" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Awarded_Block </th> <th style="text-align:left;"> Awarded_Time </th> <th style="text-align:left;"> Prize_Period_Started_At </th> <th style="text-align:left;"> Ticket_Supply </th> <th style="text-align:left;"> Prize_External_ERC20 </th> <th style="text-align:right;"> Prize_Internal </th> <th style="text-align:left;"> Pool </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> 13063959 </td> <td style="text-align:left;"> 2021-08-20 19:19:57 </td> <td style="text-align:left;"> 2021-08-13 19:00:00 </td> <td style="text-align:left;"> 27031562847149068445242853 </td> <td style="text-align:left;"> [0xc00e94cb662c3520282e6f5717214004a7f26888;4.8165099755076;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;4.8165099755076;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;4.8165099755076;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;4.8165099755076;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;4.8165099755076;Compound;COMP] </td> <td style="text-align:right;"> 6746.640 </td> <td style="text-align:left;"> DAI Pool </td> </tr> <tr> <td style="text-align:left;"> 13018758 </td> <td style="text-align:left;"> 2021-08-13 19:32:30 </td> <td style="text-align:left;"> 2021-08-06 19:00:00 </td> <td style="text-align:left;"> 30394109732258832063501193 </td> <td style="text-align:left;"> [0xc00e94cb662c3520282e6f5717214004a7f26888;3.81597064475834;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;3.81597064475834;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;3.81597064475834;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;3.81597064475834;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;3.81597064475834;Compound;COMP] </td> <td style="text-align:right;"> 7550.235 </td> <td style="text-align:left;"> DAI Pool </td> </tr> <tr> <td style="text-align:left;"> 12973196 </td> <td style="text-align:left;"> 2021-08-06 19:06:59 </td> <td style="text-align:left;"> 2021-07-30 19:00:00 </td> <td style="text-align:left;"> 30959874485348992187650102 </td> <td style="text-align:left;"> [0xc00e94cb662c3520282e6f5717214004a7f26888;3.79000297772481;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;3.79000297772481;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;3.79000297772481;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;3.79000297772481;Compound;COMP][0xc00e94cb662c3520282e6f5717214004a7f26888;3.79000297772481;Compound;COMP] </td> <td style="text-align:right;"> 7048.811 </td> <td style="text-align:left;"> DAI Pool </td> </tr> </tbody> </table> --- ## Holder Balances With the pre-processed data, the first thing we can look at is a distribution of the balances of holders. Here we use free scales, which allows us to better see each panel individually despite the large difference between the different pools. We can clearly see that most of the balances fall in the $100 - $10,000 across the various pools, but there a few holders have very large balances. ```r ## Flatten holders data have_holders <- which(sapply(holders_data,nrow)>0) h_names <- pools_data$Name[have_holders] h_val <- pools_data$Ticket_Val_Base_Tok[have_holders] h_valusd <- pools_data$Ticket_Val_USD[have_holders] h_dec <- pools_data$Base_Tok_Decimals[have_holders] h_holders <- holders_data[have_holders] holders_flat <- do.call(rbind,mapply(function(x,y,z,w,xx) cbind(x,Pool_Name=y,Value=z,USD=w,Dec=xx),h_holders,h_names,h_val,h_valusd,h_dec,SIMPLIFY=FALSE)) %>% as_tibble() %>% mutate(across(c(balance, Value, USD, Dec), as.numeric)) %>% mutate(Price = USD / Value) %>% mutate(Bal = balance / (10^Dec) * Price) my_dollars <- function(x) { ifelse(x < .01, paste0("$", x), scales::dollar(x)) } ``` --- ```r ggplot(holders_flat, aes(x = Bal)) + geom_histogram(aes(fill = Pool_Name), bins=100) + scale_x_log10(labels = my_dollars, breaks = c(1e-16, 1e-14, 1e-12, 1e-10, 1e-8, 1e-6, 1e-4, 1e-2, 1, 100, 10000, 1000000, 100000000)) + facet_wrap(~Pool_Name, scales = "free") + theme( axis.text.x = element_text(angle = 40, hjust = 1), legend.position = "off" ) ``` <img src="pool_files/figure-html/unnamed-chunk-7-1.png" style="display: block; margin: auto;" /> --- ## Holder Balances (Fixed X Axis) If we fix the x scales, we can now compare across the pools a little better, when stacking the graph like so. We can see that COMP, UNI, and others tend to have larger balances than the USDC or GUSD pools for example. ```r ggplot(holders_flat, aes(x = Bal)) + geom_histogram(aes(fill = Pool_Name), bins=100) + scale_x_log10(labels = my_dollars, breaks = c(1e-16, 1e-14, 1e-12, 1e-10, 1e-8, 1e-6, 1e-4, 1e-2, 1, 100, 10000, 1000000, 100000000)) + facet_wrap(~Pool_Name, scales = "free_y", ncol = 1) + theme( axis.text.x = element_text(angle = 20, hjust = 1), legend.position = "off" ) ``` --- <img src="pool_files/figure-html/unnamed-chunk-9-1.png" style="display: block; margin: auto;" /> --- ## Average time between rewards We can compute the mean and median time between rewards by arranging the award time, and then computing the difference between subsequent rows: ```r rewards_data1 <- rewards_data %>% bind_rows() %>% as_tibble() %>% arrange(Awarded_Time) %>% mutate(TimeBetween = c(NA, diff(Awarded_Time))) mean(rewards_data1$TimeBetween, na.rm = TRUE) ``` ``` ## [1] 2127.506 ``` ```r median(rewards_data1$TimeBetween, na.rm = TRUE) ``` ``` ## [1] 1450.067 ``` --- One method to visualize this data is to plot a histogram of the distribution. This allows us to clearly see that the typical time between rewards is around 1500 minutes, or just about a day. ```r ggplot(rewards_data1, aes(x = TimeBetween)) + geom_histogram() + scale_x_continuous(breaks = scales::pretty_breaks(n = 10)) + labs( title = "Time between Subsequent Awards", x = "Time (minutes)", ) ``` <img src="pool_files/figure-html/unnamed-chunk-11-1.png" style="display: block; margin: auto;" /> --- ## Time between rewards over time But, this obscures how the time has decreased since the start. Here we order the rewards from first to last, and plot the time between to see both the oscillating pattern as of late, and how this has settled into the ~1 day value that it is today. ```r ggplot(rewards_data1 %>% mutate(ID = 1:nrow(.)), aes(x = ID, y = TimeBetween)) + geom_point() + geom_line() ``` <img src="pool_files/figure-html/unnamed-chunk-12-1.png" style="display: block; margin: auto;" /> --- ## How many holders in more than one pool? We can perform some data manipulation in order to compute how many holders are in more than one pool. Doing so shows that about 2000 holders are in more than one pool: ```r have_holders <- which(sapply(holders_data,nrow)>0) h_names <- pools_data$Name[have_holders] n_tokens <- pools_data$Base_Tok_Name[have_holders] h_holders <- holders_data[have_holders] flat <- do.call(rbind,mapply(function(x,y,z) cbind(x,Pool_Name=y, Token_Name=z),h_holders,h_names,n_tokens,SIMPLIFY=FALSE)) %>% as_tibble() more_than_one <- flat %>% group_by(id) %>% summarise(Pools = length(unique(Pool_Name))) %>% filter(Pools > 1) more_than_one %>% count() %>% pull ``` ``` ## [1] 2038 ``` --- ## How many in exactly one pool? By checking how many are in exactly one pool, we see that this represents the majority of holders, a bit over 7000 of them. ```r flat %>% group_by(id) %>% summarise(Pools = length(unique(Pool_Name))) %>% filter(Pools == 1) %>% count() %>% pull() ``` ``` ## [1] 7404 ``` --- ## Most Pools Certain holders are in a large number of pools. At the time of this writing, the addresses below are those in the most pools. One particular holder is in 9 of the pools, and many others are in 8 of them. ```r flat %>% group_by(id) %>% summarise(Pools = length(unique(Pool_Name))) %>% arrange(desc(Pools)) %>% head(n = 5) %>% kable() %>% kable_styling(bootstrap_options = c("striped", "hover")) ``` <table class="table table-striped table-hover" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> id </th> <th style="text-align:right;"> Pools </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> 0x4e1d9cedf4d87b6bcc7c97990704927a824fd940 </td> <td style="text-align:right;"> 9 </td> </tr> <tr> <td style="text-align:left;"> 0x049d49048dcd19892b2902a230afd89e3279a0da </td> <td style="text-align:right;"> 8 </td> </tr> <tr> <td style="text-align:left;"> 0x0c6ac3fcea667fd6c62483ce1dbbce6f6ce0fb1f </td> <td style="text-align:right;"> 8 </td> </tr> <tr> <td style="text-align:left;"> 0x2c38a374d4df6b165ed86dc8a6cab2c5aa955d5a </td> <td style="text-align:right;"> 8 </td> </tr> <tr> <td style="text-align:left;"> 0x53e17b1d817a625d1eb5817b68cfaddcaa56950b </td> <td style="text-align:right;"> 8 </td> </tr> </tbody> </table> --- ## Computing Pool Diversity We can compute a metric of pool diversity by, for every holder in more than one pool, seeing the incidence that they occur with one another. From there, we can measure how similar the pools themselves are. The POOL Pool and the DAI pool have a fairly strong similarity, whereas (for example) the DAi pool and the BADGER Pool have very little similarity. ```r incidence <- flat %>% select(Address = id, Pool_Name) %>% filter(Address %in% more_than_one$id) %>% mutate(Count = 1) %>% spread(key = Pool_Name, value = Count) incidence[is.na(incidence)] <- 0 inci <- 1 - dist(incidence %>% select(-Address) %>% t, method = "binary", upper = TRUE, diag = TRUE) %>% as.matrix ``` --- ```r inci %>% as_tibble() %>% mutate(Pool = rownames(inci)) %>% select(Pool, everything()) %>% kable() %>% kable_styling(bootstrap_options = c("striped", "hover"), font_size = 14) ``` <table class="table table-striped table-hover" style="font-size: 14px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Pool </th> <th style="text-align:right;"> BADGER Pool </th> <th style="text-align:right;"> COMP Pool </th> <th style="text-align:right;"> DAI Pool </th> <th style="text-align:right;"> GUSD Pool </th> <th style="text-align:right;"> POOL Pool </th> <th style="text-align:right;"> SUSHI Pool </th> <th style="text-align:right;"> UNI Pool </th> <th style="text-align:right;"> UNI-V2 Pool </th> <th style="text-align:right;"> USDC Pool </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> BADGER Pool </td> <td style="text-align:right;"> 1.0000000 </td> <td style="text-align:right;"> 0.1294118 </td> <td style="text-align:right;"> 0.0473146 </td> <td style="text-align:right;"> 0.0596026 </td> <td style="text-align:right;"> 0.0633862 </td> <td style="text-align:right;"> 0.1145038 </td> <td style="text-align:right;"> 0.0847953 </td> <td style="text-align:right;"> 0.0734824 </td> <td style="text-align:right;"> 0.0590631 </td> </tr> <tr> <td style="text-align:left;"> COMP Pool </td> <td style="text-align:right;"> 0.1294118 </td> <td style="text-align:right;"> 1.0000000 </td> <td style="text-align:right;"> 0.1024209 </td> <td style="text-align:right;"> 0.0456140 </td> <td style="text-align:right;"> 0.1013250 </td> <td style="text-align:right;"> 0.1497006 </td> <td style="text-align:right;"> 0.1827957 </td> <td style="text-align:right;"> 0.0699774 </td> <td style="text-align:right;"> 0.1305182 </td> </tr> <tr> <td style="text-align:left;"> DAI Pool </td> <td style="text-align:right;"> 0.0473146 </td> <td style="text-align:right;"> 0.1024209 </td> <td style="text-align:right;"> 1.0000000 </td> <td style="text-align:right;"> 0.0157068 </td> <td style="text-align:right;"> 0.4447454 </td> <td style="text-align:right;"> 0.1030741 </td> <td style="text-align:right;"> 0.2250287 </td> <td style="text-align:right;"> 0.0793254 </td> <td style="text-align:right;"> 0.3889206 </td> </tr> <tr> <td style="text-align:left;"> GUSD Pool </td> <td style="text-align:right;"> 0.0596026 </td> <td style="text-align:right;"> 0.0456140 </td> <td style="text-align:right;"> 0.0157068 </td> <td style="text-align:right;"> 1.0000000 </td> <td style="text-align:right;"> 0.0145051 </td> <td style="text-align:right;"> 0.0445104 </td> <td style="text-align:right;"> 0.0218069 </td> <td style="text-align:right;"> 0.0162602 </td> <td style="text-align:right;"> 0.0269107 </td> </tr> <tr> <td style="text-align:left;"> POOL Pool </td> <td style="text-align:right;"> 0.0633862 </td> <td style="text-align:right;"> 0.1013250 </td> <td style="text-align:right;"> 0.4447454 </td> <td style="text-align:right;"> 0.0145051 </td> <td style="text-align:right;"> 1.0000000 </td> <td style="text-align:right;"> 0.1215596 </td> <td style="text-align:right;"> 0.2130137 </td> <td style="text-align:right;"> 0.0937500 </td> <td style="text-align:right;"> 0.2163433 </td> </tr> <tr> <td style="text-align:left;"> SUSHI Pool </td> <td style="text-align:right;"> 0.1145038 </td> <td style="text-align:right;"> 0.1497006 </td> <td style="text-align:right;"> 0.1030741 </td> <td style="text-align:right;"> 0.0445104 </td> <td style="text-align:right;"> 0.1215596 </td> <td style="text-align:right;"> 1.0000000 </td> <td style="text-align:right;"> 0.1404151 </td> <td style="text-align:right;"> 0.0709939 </td> <td style="text-align:right;"> 0.1189827 </td> </tr> <tr> <td style="text-align:left;"> UNI Pool </td> <td style="text-align:right;"> 0.0847953 </td> <td style="text-align:right;"> 0.1827957 </td> <td style="text-align:right;"> 0.2250287 </td> <td style="text-align:right;"> 0.0218069 </td> <td style="text-align:right;"> 0.2130137 </td> <td style="text-align:right;"> 0.1404151 </td> <td style="text-align:right;"> 1.0000000 </td> <td style="text-align:right;"> 0.0735484 </td> <td style="text-align:right;"> 0.1574981 </td> </tr> <tr> <td style="text-align:left;"> UNI-V2 Pool </td> <td style="text-align:right;"> 0.0734824 </td> <td style="text-align:right;"> 0.0699774 </td> <td style="text-align:right;"> 0.0793254 </td> <td style="text-align:right;"> 0.0162602 </td> <td style="text-align:right;"> 0.0937500 </td> <td style="text-align:right;"> 0.0709939 </td> <td style="text-align:right;"> 0.0735484 </td> <td style="text-align:right;"> 1.0000000 </td> <td style="text-align:right;"> 0.0741445 </td> </tr> <tr> <td style="text-align:left;"> USDC Pool </td> <td style="text-align:right;"> 0.0590631 </td> <td style="text-align:right;"> 0.1305182 </td> <td style="text-align:right;"> 0.3889206 </td> <td style="text-align:right;"> 0.0269107 </td> <td style="text-align:right;"> 0.2163433 </td> <td style="text-align:right;"> 0.1189827 </td> <td style="text-align:right;"> 0.1574981 </td> <td style="text-align:right;"> 0.0741445 </td> <td style="text-align:right;"> 1.0000000 </td> </tr> </tbody> </table> --- ## Tokens in Reward Pools Finally, we can see the occurrences of particular tokens within each reward pool: ```r res <- sapply(1:nrow(rewards_data1), function(i) { x <- rewards_data1$Prize_External_ERC20[i] do.call(rbind, strsplit(gsub("\\[|\\]", "", strsplit(x, "][", fixed = TRUE)[[1]]), ";")) %>% as_tibble() %>% mutate(Pool = rewards_data1$Pool[i]) }) %>% bind_rows() %>% rename(Address = V1, Amount = V2, Name = V3, Ticker = V4) %>% mutate(Amount = readr::parse_number(Amount)) final <- res %>% group_by(Pool, Ticker) %>% summarise(Count = n()) %>% spread(key = Ticker, value = Count) final[is.na(final)] <- 0 ``` --- ```r final %>% head(n = 10) %>% select(1:12) %>% kable() %>% kable_styling(bootstrap_options = c("striped", "hover")) ``` <table class="table table-striped table-hover" style="margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Pool </th> <th style="text-align:right;"> 0xBTC </th> <th style="text-align:right;"> ٨ </th> <th style="text-align:right;"> AAVE </th> <th style="text-align:right;"> ALEPH </th> <th style="text-align:right;"> ALEX </th> <th style="text-align:right;"> BAT </th> <th style="text-align:right;"> BEL </th> <th style="text-align:right;"> BOI </th> <th style="text-align:right;"> BOOKS </th> <th style="text-align:right;"> BUILD </th> <th style="text-align:right;"> CER </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> BADGER Pool </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> COMP Pool </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> DAI Pool </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 1 </td> <td style="text-align:right;"> 2 </td> </tr> <tr> <td style="text-align:left;"> GUSD Pool </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> POOL Pool </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> SUSHI Pool </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> UNI Pool </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> UNI-V2 Pool </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> USDC Pool </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 0 </td> </tr> </tbody> </table>