-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable tracking the accrued interest #314
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouf, missed this one thanks
|
No because the |
It can be recovered from the last |
Its ok while we can recover it from prev event |
Ok, I'm removing the field |
Just want to make sure that it's crystal clear: you won't be recovering it from the previous event of the same type: you need to recover it from the previous event of the type |
…ount-interest-accrued
Motivated by a remark of @tomrpl, thanks !
Before this PR, the events
AccrueFee(uint256 feeShares)
andUpdateLastTotalAssets(uint256 newTotalAssets)
were emitted at each interaction. Those are not enough to compute the actual yield generated by the vault because:feeShares
could be 0, if the vault does not take any performance fee we can't recompute the whole interest generatednewTotalAssets
takes into account the funds added by the current interaction. Those funds are not part of the interest generated and are difficult to subtract (it depends on each interaction)To fix this, the event
AccrueFee
is transformed intoAccrueInterest
to add 2 fields:lastTotalAssets
, the value of the storage variable of the same name before the interaction. It is provided as a convenience to be able to reconstruct the yield by looking only at eventsaccruedTotalAssets
, the total assets in the vault before the interaction, after having accrued the interestWith those, one can compute
(accruedTotalAssets - lastTotalAssets) / lastTotalAssets
to compute the yield generated during 2 interactions.