Dune Analytics is the tool I’d been quietly waiting for since I first collided with crypto and data analytics in 2017: a SQL interface to nearly everything happening on-chain — transparent, real-time, and open to anyone. So when a job application handed me a set of questions to answer on Dune, I was a little too happy to oblige. Here’s how I approached the assignment, and then some. Final result here.

One of the biggest hurdles to overcome was understanding what tables hold the relevant data. A lot of this can be achieved with just the search bar, but understanding the functions of the protocol and the events it emits gives a more comprehensive view. Compound is (or at least was) a relatively straightforward protocol as it’s transactions don’t call many other protocols in order to execute.
One way to learn about the functions of a protocol is going into the contract tab on the protocol’s page on etherscan. The functions listed there more or less correspond with the decoded tables on Dune. 
Once I know what the relevant tables are, I look at individual transactions and cross-reference them with their Etherscan pages to make sure the decoding in my query reflects the “truth”. 
To give more details, this was my process querying question 1 in assignment prompt:
PS I noticed a distortion in Dune’s rendering functionality on my gas and PnL graph. The scaling is a bit off: only y points < ~1,000 show up below zero. More importantly, a y axis point = -314 (on the left screenshot) appears higher than y = -1,054 (center) and at the same time so close to y = 12,021 (right). I asked the question on dune’s discord and a “wizard” told me that “when you have that many data, scatter doesn’t really work well”. That graph had 9255 data points. 