How can I calculate newInterest each time ReserveDataUpdated is emitted?


Hello! I am building an Aave v2 subgraph and I am trying to figure out how I can calculate `newInterest` each time `ReserveDataUpdated` is emitted? Does anyone know how I could use the liquidityIndex to figure this out? I understand that interest in a `market = currentATokenBalance - scaledATokenBalance` Trying to calculate accrued interest for an entire pool. So the link you send is to calculate all of the interest accrued and not realized (aka depositors have not withdrawn that interest yet)? What I am trying to calculate is new interest that has accrued in an asset pool since the last transaction in that pool. We are trying to get timeseries data in our subgraph for new daily revenues.

Answers 1

You can do this two ways: 1) Track the difference in `totalATokenSupply `factoring in any mints/burns from the current action 2) `totalDeposits `* difference in `liquidityIndex `from previous action More [info](