Last year I discovered Dune Analytics, but forgot to blog about it. Dune is a blockchain querying interface, which I’ve been waiting for since I first learned about crypto and data analytics in 2017. Dune encapsulates open finance values, such as transparent accessible data, open-source real-time intel, distributed ledgers. So when I was given some questions to query on Dune as part of a job application, I was excited to try this very pleasant way of accessing everything happening on blockchain. Here is how I approached the assignment and then some. Final result
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 reflect 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.