1 Gather the data

Flipside’s API allows us to pull query results hosted on the Velocity platform.

The following function is used to import data from Velocity:

PullVelocityData <- function(endpoint.url){
  raw.results <- readLines(endpoint.url)
  to.return <- data.table(jsonlite::fromJSON(raw.results))
  setnames(to.return, tolower(names(to.return)))
  return(to.return)
}

We import our query results from Velocity.

aave.data <- PullVelocityData("https://api.flipsidecrypto.com/api/v2/queries/8e2b64a4-5f2c-4de2-8e42-1853ae70e151/data/latest")

aave.data$date <- as.Date(aave.data$date)
aave.data3 <- PullVelocityData("https://api.flipsidecrypto.com/api/v2/queries/60062101-3228-4075-8d16-0258847665ff/data/latest")
aave.data3$date <- as.Date(aave.data3$date)

1.1 Visualizing the Correlation with Scatterplots

Correlation is the tendency for the values of two or more variables to vary together in a related way. It can be seen as a pattern in a scatter plot graph. Correlation coefficients are standardized. Values can range from -1 to 1 where a negative value means that the two variables move in opposite directions. A value of 1 indicates a perfectly linear relationship.

2 Scatterplots of Average Borrow and Deposit Amounts VS Gas Fee, over Four Months

b3 <- ggplot(aave.data3, aes(x = mean_fee, y = avg_borrowed), digits = 2)
d3 <- ggplot(aave.data3, aes(x = mean_fee, y = avg_deposit))
plot_grid(b3 + geom_point(color = "red")+
stat_cor(method = "pearson", 
label.x = 50, label.y = 3000000, digits = 2)+ scale_y_continuous(breaks=c(1000000,2000000,3000000,4000000)) + ylim(0, 4000000), d3 + geom_point(colour = "dark green")+
stat_cor(method = "pearson", 
label.x = 50, label.y = 3000000), labels = "AUTO")

The correlation coefficient with gas fee is 0.45 for the daily average borrow amount and 0.38 for the daily average deposit amount. This indicates a weak but not negligible correlation.

3 Scatterplots of the Number of Small Deposits and Loans VS Gas Fee, over Four Months

b <- ggplot(aave.data, aes(x = mean_fee, y = nb_small_borrows))
d <- ggplot(aave.data, aes(x = mean_fee, y = nb_small_deposits))
plot_grid(b + geom_point(color = "red")+
stat_cor(method = "pearson", 
label.x = 50, label.y = 125, digits = 2), d + geom_point(colour = "dark green")+
stat_cor(method = "pearson", 
label.x = 50, label.y = 420), labels = "AUTO")

Note: the y-axis of the two plots has a different scale. Reminder: small borrows and deposits are valued under 3,000 USD.

By observing both plots we see that a gas fee of 30 USD appears to be associated with a decrease in small deposits and a sharp decrease in small loans.

The correlation coefficient with the gas fee is -0.69 for the daily number of small deposits and -0.58 for the daily number of small loans. This is categorized as a strong inverse association. Transaction costs appear to have a significant impact on small loans and deposits.

4 Limitations

Our analysis does not prove that transaction costs cause a change in borrows and deposits. We only observe the correlation between the variables. Our data sets include a four month observation period. Calculating the correlation using a full year of data could increase our confidence in the result.

5 Conclusion

What have we learned?

  1. There is a small correlation between the transaction costs (gas fee) and the daily average borrow and deposit amounts;
  2. The average borrow and deposit amounts are much larger than the price of gas;
  3. Transaction costs appear to have a larger impact on small deposits and loans;
  4. There is a significant negative correlation between transaction costs and the daily number of borrows and deposits. In other words there are less small loans and deposits during times of high gas price;
  5. A gas price of 30 USD appear to be the threshold where small loans and deposits decrease the most abruptly.

special thanks to: - Ryan_Loofy for his Aave starter query on deposits and withdrawals; and - Erics for his starter query on the average Eth fee paid by hour.