embrio-tech / centrifuge-subql

Subquery for Pools on Centrifuge Chain and Altair
https://explorer.subquery.network/subquery/embrio-tech/centrifuge-subql
MIT License
0 stars 1 forks source link

Track accrued interest per period #234

Closed hieronx closed 7 months ago

filo87 commented 7 months ago

@hieronx, should that be tracked at single loan level? or aggregated at pool level? At what entity do you need this?

hieronx commented 7 months ago

@filo87 this was related to the P&L statement, so should be at the pool level. I imagine a sumInterestAccruedByPeriod property in PoolSnapshot

filo87 commented 7 months ago

@hieronx Can we compute this as the variation in outstandingInterestfrom the portfolio call? What if there are Interest Repayments?

hieronx commented 7 months ago

@filo87 yeah I think it should be outstandingInterest + repaidInterestAmountByPeriod - outstandingInterestPreviousPeriod

Say the interest outstanding was previously 12 USDC, there is 1 USDC interest accrual per day, and there was an interest repayment of 5. Then new outstanding interest would be 8. We can derive interest accrued based on 5 + 8 - 12 = 1 USDC.