How to calculate the Aave TVL using Dune analytics?
- Aave Protocol
- Aave v2 Aave
I'm trying to calculate the Aave TVL using Dune analytics. I'm not actually sure which events I need to look at to get an accurate aggregation... namely because there's interest.
My logic was net all the the transfer events to and from Aave v2, but that metric doesn't account for interest.
That's a hard duty given how dune analytics work by events, but in case it helps:
- Events that bring up HF => Supply/Deposit, repayments & liquidations;
- Events that bring down HF => Withdraw/Borrow;
- Also transfers might affect HF, if atokens are transferred;
- And supply only matters for those assets that are enabled (or can be used) as collateral;
Another way, in case its more simple, would be taking into account balance of atokens acting as collateral, versus debt tokens and do the maths from there.