A comparison of historical variable borrow rates for USDC on Aave

Fundamental Crypto
Covalent
Published in
1 min readApr 7, 2021

--

Welcome to the third technical article in our article series. As always, I will try to keep it short and sweet and up to the point. I like to write the “snack format” articles and this article will be no exception :)

When we first try to tackle this task, it’s not as intuitive as it seems. When browsing the docs page for Covalent we can see, that there exists a Get Aave v2 network assets endpoint. So that’s it, you say? No so fast :)

An attentive reader will discover that this endpoint will show you the latest data, not historical data. As such, we would need to find some other way to show historical data. Sooo — let the fun begin!

Rate changes are encoded in events, and Covalent can index them. Therefore, we can extract all events that pertain to Aave rate changes. The specific event in which we are interested is called ReserveDataUpdated and it lives in the LendingPool contract. I will leave it as homework for the reader to find the Aave contract address list. With a bit of hacking, here’s the code with detailed comments.

Code, which extracts historical variable APR

The following code should produce the following result:

Variable borrow APR

Having these results now it is trivial to visualize the historical rates.

Aaaand that’s it! As promised .. less text and more code!

Twitter: @Covalent_HQ
Telegram: https://www.covalenthq.com/telegram/
Discord: https://www.covalenthq.com/discord

--

--